Skip to main content

Simple arithmetic lib for students

Project description

_rithmetic_

“rithmetic” is a budding python package which aims to provide arithmetic and math assistance to students using python to build math related functionality or apps.

How to Install:

Run the following command in Terminal/CLI –

  • pip install rithmetic

After installation completes, run the following command in Terminal/CLI to see the welcome message –

  • rith

To check for the version of rithmetic run the following command in Terminal/CLI –

  • rith-version

License and terms of use:

rithmetic comes with the MIT license which means that anyone, anywhere can use it for any open source or even closed source application.

Current functionality:

  1. Convert a positive integer from one base to another (Converters)
  2. Check/Verify if a positive integer is from a specified base (Verifiers)

Best way to import:

Import all the functions from rithmetic at once

from rithmetic import *

Functions:

Converters

base(num, fromB, toB)

Converts any positive integer from one base to another. (supported bases are base-2 to base-16)

num – any positive integer | can be both int and str type

fromB – base of ‘num’ | can be both int and str type

toB – ‘num’ gets converted to this base | can be both int and str type

Returns – The converted Integer OR ‘Invalid number’ OR ‘Invalid base value’

Example:

from rithmetic import *

number = base(1111,2,16)
print(number)

This will print ‘F’. As 1111 which is a binary number gets converted to F in hexadecimal.

dectosub(num, toB)

Converts any positive integer from Decimal to any other sub-decimal base. (supported bases are base-2 to base-9)

num – any positive integer | can be both int and str type

toB – ‘num’ gets converted to this base | can be both int and str type

Returns – The converted Integer OR ‘Invalid number’ OR ‘Invalid base value’

Example:

from rithmetic import *

number = dectosub(23,5)
print(number)

This will print 43. As 23 which is a decimal number gets converted to 43 in base-5.

subtodec(num, fromB)

Converts any positive integer from any sub-decimal base to Decimal. (supported bases are base-2 to base-9)

num – any positive integer | can be both int and str type

fromB – base of ‘num’ | can be both int and str type

Returns – The converted Integer OR ‘Invalid number’ OR ‘Invalid base value’

Example:

from rithmetic import *

number = subtodec(25,6)
print(number)

This will print 17. As 25 in base-6 gets converted to 17 in decimal.

Quick single parameter converters

  • Decimal to another base:

dectob2(num)

dectob3(num)

dectob4(num)

dectob5(num)

dectob6(num)

dectob7(num)

dectob8(num)

dectob9(num)

dectob11(num)

dectob12(num)

dectob13(num)

dectob14(num)

dectob15(num)

dectob16(num)

num – any positive integer | can be both int and str type

Return – The converted Integer OR ‘Invalid number’

  • Any base to Decimal

b2todec(num)

b3todec(num)

b4todec(num)

b5todec(num)

b6todec(num)

b7todec(num)

b8todec(num)

b9todec(num)

b11todec(num)

b12todec(num)

b13todec(num)

b14todec(num)

b15todec(num)

b16todec(num)

num – any positive integer | can be both int and str type

Return – The converted Integer OR ‘Invalid number’

Verifiers

chkbase(num, base)

Checks if a positive integer is from a specified base. (supported bases are base-2 to base-16)

num – any positive integer | can be both int and str type

base – base of ‘num’ to be checked | can be both int and str type

Returns – True OR False OR ‘Invalid base value’ OR 'Invalid number'

Example:

from rithmetic import *

check = chkbase('23F',16)
print(check)

This will print True. As 23F is from base-16.

Quick single parameter verifiers

chk2(num)

chk3(num)

chk4(num)

chk5(num)

chk6(num)

chk7(num)

chk8(num)

chk9(num)

chk10(num)

chk11(num)

chk12(num)

chk13(num)

chk14(num)

chk15(num)

chk16(num)

num – any positive integer | can be both int and str type

Return – True OR False OR 'Invalid number'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rithmetic-0.0.13.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rithmetic-0.0.13-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file rithmetic-0.0.13.tar.gz.

File metadata

  • Download URL: rithmetic-0.0.13.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for rithmetic-0.0.13.tar.gz
Algorithm Hash digest
SHA256 c01d8b7dd31fabe1e5728fb8444c14d5e80674624215d3875ce58b56a20ce22f
MD5 2409a80bccf0bc1e27f8bc691d068558
BLAKE2b-256 e5549c72f34c4b6eef9f47054d8520d9395ec61e15907c3997a7664d07641c18

See more details on using hashes here.

File details

Details for the file rithmetic-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: rithmetic-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for rithmetic-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 fc3b7466ea4a58560e719c7b59962357ad14cef01672c309d9dcf21cd6acf5d6
MD5 c4331525af161acf1936d4defe26e61f
BLAKE2b-256 1f99323cc23db643c973d9b4506960b4dcbfe35e2054c08e4ba7e5895856fc51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page