Skip to main content
Thank you for installing simple_math.
You can contact me for problems, bugs, and suggetions of simple_math at
noahmouse2011@gmail.com



What's new in simple_math 1.1.0


almost ALL functions had a performance boost

removed useless changing whole number to int's in certain functions

exno has added optional argument "powers"
now works correctly with floating-point-numbers

mode only uses one argument

pvint and pvfloat have both been replaced by plval
old definitions are now wrappers but will be removed
in future update

factors now includes n for factors(n)

prifac can now compute for numbers with number
of prime factors > 1000

median works for unsorted lists

probably many more bug fixes that are unknown to
me at the time



Info about newest functions

exno(num:int, powers:bool = False) --> str
Return the Expanded Notation of "num" as a string

>>> simple_math.exno(325)
'( 3 * 100 ) + ( 2 * 10 ) + ( 5 * 1 )'
>>> simple_math.exno(30201)
'( 3 * 10000 ) + ( 2 * 100 ) + ( 1 * 1 )'
>>> simple_math.exno(30201.023)
'( 3 * 10000 ) + ( 2 * 100 ) + ( 1 * 1 ) + ( 2 * 0.01 ) + ( 3 * 0.001 )'
>>> simple_math.exno(30201.023,powers=True)
'( 3 * 10**4 ) + ( 2 * 10**2 ) + ( 1 * 10**0 ) + ( 2 * 10**-2 ) + ( 3 * 10**-3 )'
>>> simple_math.exno(1,powers=True)
'( 1 * 10**0 )'
>>>



factors(num:int) --> list
Return all factors of an int as a list
Raises ValueError for negitive or
floating point numbers

>>> simple_math.factors(10)
[1, 2, 5, 10]
>>> simple_math.factors(100)
[1, 2, 4, 5, 10, 20, 25, 50, 100]
>>> simple_math.factors(83) # prime number
[1, 83]
>>>



gcf(num1:int,num2:int) --> int
Return the Greatest Common Factor of two numbers
Already implemented in module "fractions" (and "math" in python 3.5)
may remove in future

>>> simple_math.gcf(4,6)
2
>>> simple_math.gcf(1,1000)
1
>>> simple_math.gcf(20,10)
10
>>>



gcfl(l:list) --> int
Return the Greatest Common Factor of a list of numbers

>>> simple_math.gcfl([4,6,8,10])
2
>>> simple_math.gcfl([15,12,9,6])
3
>>> simple_math.gcfl([number for number in range(100)]) #l=[0,1,2,3,4,5 ... 99]
1
>>>



lcd(num1:int,num2:int) --> int
Return the Least Common Denominator of two numbers

>>> simple_math.lcd(2,3)
6
>>> simple_math.lcd(14,7)
14
>>> simple_math.lcd(1000,1001)
1001000
>>>



lcdl(l:list) --> int
Return the Least Common Denominator of a list of numbers

>>> simple_math.lcdl([1,2,3])
6
>>> simple_math.lcdl([12,6,18])
36
>>> simple_math.lcdl([0,1,2,3,4,5])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "simple_math.py", line 128, in lcdl
raise ValueError('invalid number "0"')
ValueError: invalid number "0"
>>>



mean(l:list) --> float
Return the Mean (Average) of a list of numbers

>>> simple_math.mean([1,2,3])
2.0
>>> simple_math.mean([3])
3.0
>>> simple_math.mean([9,4,10])
7.666666666666667
>>> simple_math.mean([1,2,3,4])
2.5
>>>



median(l:list) --> float
Return the Median of a list of numbers

>>> simple_math.median([1,2,3])
2.0
>>> simple_math.median([6,2,0,4,8])
4.0
>>> simple_math.median([6,2,0,4,8,5])
4.5
>>> simple_math.median([6,2,0,4,8,8])
5.0
>>>



mode(l:list) --> list
Return the Mode(s) in a list

>>> simple_math.mode([])
[]
>>> simple_math.mode([3])
[3]
>>> simple_math.mode([1,2,3,4,5,6])
[1, 2, 3, 4, 5, 6]
>>> simple_math.mode([1,2,3,4,5,6,6])
[6]
>>> simple_math.mode([1,2,3,4,5,6,6,1])
[1, 6]
>>>



pvint(num:int, place_value:int = 1) --> int
This is an old function and is replacable by plval
Will be removed in future versions



pvfloat(num:float, place_value:float = 1.0)
This is an old function and is replacable by plval
Will be removed in future versions



plval(num:float, place_value:int = 0)
Return the Place Value of a number
Place_value refers to n where the specified digit is in the 10^n slot
Raises ValueError if place value provided is invalid

>>> simple_math.plval(123)
3
>>> simple_math.plval(1024,3)
1
>>> simple_math.plval(1024.1024,-3)
2
>>>



prifac(num:int) --> list
Return the Prime Factorization of num in a list

>>> simple_math.prifac(8)
[2, 2, 2]
>>> simple_math.prifac(6)
[2, 3]
>>> simple_math.prifac(2*3*5*7)
[2, 3, 5, 7]
>>> simple_math.prifac(0) # 0 < 2
[]
>>>



prime(num:int) --> bool
Return True if num is a prime number and False if not

>>> simple_math.prime(3)
True
>>> simple_math.prime(4)
False
>>> simple_math.prime(13)
True
>>> simple_math.prime(1)
False
>>> simple_math.prime(-1)
False
>>>



primes_to(num:float) --> list
Return a list of all the primes up to a number

>>> simple_math.primes_to(10)
[2, 3, 5, 7]
>>> simple_math.primes_to(0)
[]
>>> simple_math.primes_to(17)
[2, 3, 5, 7, 11, 13, 17]
>>>



psr(num:int):
Return true if num has a Perfect Square Root and false otherwise

>>> simple_math.psr(4)
True
>>> simple_math.psr(5)
False
>>> simple_math.psr(0)
True
>>> simple_math.psr(123**2)
True
>>>



refine(string:str, variables:list = []) --> str
Return a parsed math term mostly readable by python
eg. .25 -> 0.25 , 2x(54/3) -> 2*x*(54/3) ,
| 1-x^3 \|/{10-4} -> (abs (1-x**3) )/(10-4) etc.
second parameter is a list of single character
reserved as unknown values
Not fully reliable
Will be changed in future versions

>>> simple_math.refine('.25')
'0.25'
>>> simple_math.refine('2x(54/3)',['x'])
'2*x*(54/3)'
>>> simple_math.refine('| 1-x^3 \| /{10-[4]}',['x'])
'(abs (1-x**3) )/(10-(4))'
>>> simple_math.refine('y=x^2',['x','y']) # bug!
'y*=*x**2'
>>>

Release files for simple_math 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple_math 1.1.0
File Size Uploaded
simple_math-1.1.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simple_math 1.1.0
File Interpreter ABI Platform
simple_math-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / simple_math-1.1.0.tar.gz

Download URL simple_math-1.1.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
108dc26d1425cff52ff6af1d54336dbe855be64e6febe0e8bf788def4b86079f
BLAKE2b-256 checksum
How to use checksums
8f280c002e9e57a586fc6b141f5ceb4912c2a6030ac02f3bec5165a189b8640d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / simple_math-1.1.0-py3-none-any.whl

Download URL simple_math-1.1.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8fd3dbee88e776aa6b02137e055263c84961457a99a35379008e76ebaddda49
BLAKE2b-256 checksum
How to use checksums
1b979c89ffbfe3b9b2f6c6111d995cefe4bbab1ef130b67307690166e9e51366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page