Skip to main content

A basic calculator

Project description

Change Log

0.0.6 (5/06/2021) -Sixth Release

Added

New

-version() - method -info() - method

Physics Math

New type of calculation of basic physics

Moefied

-galtoL() - method -Ltogal() - method

Change Log

0.0.6 (5/06/2021) -Sixth Release

Added

New

-version() - method -info() - method

Physics Math

New type of calculation of basic physics

Moefied

-galtoL() - method -Ltogal() - method License-File: LICENCE.txt

License: MIT made-with-python

Toncalculator

It is a simple calulator for addition, subtraction, multiplication,division, squire, to the power, sqire root, log, factorial, sin, cos, tan, cot, sec, cosec, nCr etc. iThere are many mathmatical conversions.

How To Use

Installation:

Firstly you need to install the Toncalculator module by pip install Toncalculator command. Then you need to make a .py file or open python interpreter. Finally you can write you code.

Example

import toncalculator

toncalculator.add(2,6)

Codes:

Addition:

add() method is uaed to add two numbers add(x,y) the function needs two compulsoy parameter.

Example:

result(add(1,2))

Output: 3

Subtraction:

sub() method is used to subtract 1st parameter by 2nd parameter.

Example:

result(sub(2,1))

Output : 1  

Multiplication:

mul() methed is used to multiply two numberas.

Example:

result(mul(2,3))

Output : 6

Division:

div() method is used to divie 1st number by 2nd number.

Example:

result(dev(10,2))

Output : 5

Squre:

square() method is used to squire any numbers ```

Example:

result(square(2))

Output : 4

To The Power:

power() method is used as 2nd parameter to the power of 1st parameter.

Example:

result(power(2,4))

Output : 16

Square Root:

sqroot() method is used to square root a number.

Example:

result(sqroot(16))

Output : 4    

Log:

log() method returns the natural logarithm of a number, or the logarithm of number to base.

Syntx:

log(x, base)

Parameter Values

Parameter Description
x Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError
base Optional. The logarithmic base to use. Default is 'e'

Example:

result(log(10))

Output : 2.302585..............

Factorial:

The factorial() method returns the factorial of a number.

Note: This method only accepts positive integers.

The factorial of a number is the sum of the multiplication, of all the whole numbers, from our specified number down to 1. For example, the factorial of 6 would be 6 x 5 x 4 x 3 x 2 x 1 = 720

Syntx:

factorial(x)

Parameter Values:

Parameter Description
x Required. A positive integer. If the number is negative, or not an integer, it returns a ValueError. If the value is not a number, it returns a TypeError

Example:

result(factorial(3)):

Output : 6

Sin:

sin() method returns the sine of a number.

Note: To find the sine of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

sin(x)

Parameter Values:

Parameter Description
x Required. The number to find the sine of. If the value is not a number, it returns a TypeError

Example:

# It returns normally sin of 0 redian 
result(sin(0))
# sin() returns the sin of redian.
# degTored() convers dgree to redian 
result(sin(degTored(90)))

Output : 0 
Output : 1

Cos:

cos() method returns the cosine of a number.

Note: To find the cosine of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

cos(x):

Parameter Values:

Parameter Description
x Required. The number to find the sine of. If the value is not a number, it returns a TypeError

Example:

# It returns normally cosin of 0 redian 
result(cos(0))
# cos() returns the cosin of redian.
# degTored() convers dgree to redian 
result(cos(degTored(180)))

Output : 1
Output : -1

Tan:

tan() method returns the tangent of a number.

Note: To find the tan of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

tan(x):

Parameter Values:

Parameter Description
x Required. The number to find the tangent of. If the value is not a number, it returns a TypeError

Example:

# It returns normally tangent of 0 redian 
result(tan(0))
# tan() returns the cosin of redian.
# degTored() convers dgree to redian 
result(tan(degTored(10)))

Output : 0
Output : 0.176326......

Cot:

cot() method returns the cotangent of a number.

Note: To find the cotangent of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

cot(x)

Parameter Values:

Parameter Description
x Required. The number to find the cotangent of. If the value is not a number, it returns a TypeError

Example:

# It returns normally cotangent of 0 redian 
result(cot(0))
# cot() returns the cotangent of redian.
# degTored() convers dgree to redian 
result(cot(degTored(10)))

Output : Infinity
Output : 5.6712818196......

Sec:

sec() method returns the secant of a number.

Note: To find the secant of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

sec(x)

Parameter Values:

Parameter Description
x Required. The number to find the secant of. If the value is not a number, it returns a TypeError

Example:

# It returns normally secant of 0 redian 
result(sec(0))
# sec() returns the secant of redian.
# degTored() convers dgree to redian 
result(sec(degTored(180)))

Output : 1
Output : -1

Cosec:

cosec() method returns the secant of a number.

Note: To find the secant of degrees, it must first be converted into radians with the degTored() method (see example below).

Syntx:

sec(x)

Parameter Values:

Parameter Description
x Required. The number to find the cosecant of. If the value is not a number, it returns a TypeError

Example:

# It returns normally cosecant of 0 redian 
result(sec(0))
# cosec() returns the cosecant of redian.
# degTored() convers dgree to redian 
result(cosec(degTored(90)))

Output : Infinity
Output : 0

nCr:

nCr() method returns the nCr.

Note: return the combination is the method of selection of 'r' objects from a set of 'n' objects where the order of selection does not matter.

Syntx:

nCr(n,r)

Parameter Values:

Parameter Description
n Required. Type integer
r Required. Type integer
result(nCr(9,3))

Output : 84

Mathmathical conversion

Angle Conversions

Dgree To Radian

degTored() method returns dgree to radian.

Syntx

degTored(x)

Parameter Values:

Parameter Description
x Required. x means x dgree

Example

result(degTored(180))
 
Output : 3.1416   

Radian To Dgree

redTodeg() method returns radian to dgree.

Syntx

redTodeg(x)

Parameter Values:

Parameter Description
x Required. x means x radian

Example

result(redTodeg(1))
 
Output : 57.297795

Dgree To Minute

degTomin() method returns dgree to minute.

Syntx

degTomin(x)

Parameter Values:

Parameter Description
x Required. x means x dgree

Example

result(degTomin(1))

Output : 60

Minute to Degree

minTodeg() method returns minute to dgree.

Syntx

minTodeg(x)

Parameter Values:

Parameter Description
x Required. x means x minute

Example

result(minTodeg(60))

Output : 1

Degree to Second

degTosec() method returns dgree to second.

Syntx

degTosec(x)

Parameter Values:

Parameter Description
x Required. x means x dgree

Example

result(degTosec(1))

Output : 3600

Second to Dgree

secTomin() method returns second to dgree.

Syntx

secTodeg(x)

Parameter Values:

Parameter Description
x Required. x means x second

Example

result(secTodeg(3600))

Output : 1

Minute to Second

minTosec() method returns minute to second .

Syntx

minTosec(x)

Parameter Values:

Parameter Description
x Required. x means x minute

Example

result(minTosec(1))

Output : 60

Second To Minute

secTomin() method returns second to minute.

Syntx

secTomin(x)

Parameter Values:

Parameter Description
x Required. x means x second

Example

result(secTomin(60))

Output : 1

Length Conversions

inches to centimeters

inTocm() method returns inches to centimeters.

Parameter Values:

Parameter Description
x Required. x means x inches

Example

result(inTocm(100))

Output : 254

centimeters to inches

cmToin() method returns inches to centimeters.

Parameter Values:

Parameter Description
x Required. x means x centimeters

Example

result(inTocm(254))

Output : 100

feet to meters

ftTom(x) method returns feet to meters.

Parameter Values:

Parameter Description
x Required. x means x feet

Example

result(ftTom(100))

Output : 30.48

feet to meters

mToft(x) method returns meters to feet.

Parameter Values:

Parameter Description
x Required. x means x meters

Example

result(mToft(1))

Output : 3.280839895013123

yard to meter

mToft(x) method returns yard to meter.

Parameter Values:

Parameter Description
x Required. x means x yard

Example

result(ydTom(1))

Output : 0.9144

meter to yard

mToft(x) method returns meter to yard.

Parameter Values:

Parameter Description
x Required. x means x meter

Example

result(ydTom(1))

Output : 1.0936132983377078
def mileTokm(x):
    #return x mile to kilometre
    return x/0.621367
def kmTomile(x):
    #return x kilometre to mile
    return x*0.621367
def n_mileTom(x):
    #return x notical mile to meter
    return x*1852
def mTon_mile(x):
    #return x meter to notical mile
    return x/1852
def pcTokm(x):
    #return x parsec to kilometre
    return x*3.08567758128E+13
def kmTopc(x):
    #return x kilometre to parsec
    return x/3.08567758128E+13
## Area Conversions ##
def acreTomsq(x):
    #return x acre to squire meter
    return x/0.000247105
def msqToacer(x):
    #return x squire meter to acre 
    return x*0.000247105
## Volume Conversions ##  
def galToL(x):
    #return x galon to liter you must select type here US or UK
    if type == "US" or "us" or "Us":
        return x*3.785412
    elif type == "Uk" or "UK" or "uk":
        return x*4.54609
    else:
        if type == None or type == "":
            print("[-] Error 404 type is empty")
        else:
            print("[-] Error you are not setected US or UK")
def LTogal(x):
    #return x liter to galon you must select type here US or UK
    if type == "US" or "us" or "Us":
        return x/3.785412
    elif type == "Uk" or "UK" or "uk":
        return x/4.54609
    else:
        if type == None or type == "":
            print("[-] Error 404 type is empty")
        else:
            print("[-] Error you are not setected US or UK")
## Mass Conversions ##
def ozTog(x):
    #return x ounces to grams
    return x*28.34952 
def gTooz(x):
    #return x grams to ounces   
    return x/28.34952
def lbTokg(x):
    #return x pounds to kilograms
    return x*0.45359237 
def kgTolb(x):
    #return x kilograms to pounds
    return x/0.45359237 
## Velocity Conversions ##
def kmphTomps(x):
    #return x kilometre/hour to meter/second
    m = x*1000
    s = 3600
    return m/s
def mpsTokmph(x):
    #return x meter/second to kilometre/hour
    km = x/1000
    h = 1/3600
    return km/h
## Pressure Conversions ##

def atmToPa(x):
    #retunrn x atmosphere to pascal
    return x*101325
def PaToatm(x):
    #return x pascal to atmosphere
    return x/101325
def mmHgToPa(x):
    #return x millimetre of mercury to pascal
    return x*133.322365 
def PaTommHg(x):
    #return x pascal to millimetre of mercury
    return x/133.322365 
## Energy Conversions ##
def kgfToJpm(x):
    #return Kilogram-force to Joule/meter 
    return x*9.80665 
def JpmTokgf(x):
    #return Joule/meter to Kilogram-force
    return x/9.80665
def JTocal(x):
    #return Joule to Calories
    return x*4.184
def calToJ(x):
    #return Calories to Joule
    return x/4.184
## Power Conversions ##
def hpToKW(x):
    #return Horse Power to kilowatt
    KW = {
        "mechanical": x/745.699872,
        "electrical" : x/746,
        "metric" : x/0.73549875
    }
    return KW
def KWTohp(x):
    #return Horse kilowatt to Power 
    hp = {
        "mechanical": x/745.699872,
        "electrical" : x/746,
        "metric" : x/0.73549875
    }
    return hp
## Temperature Conversions ##
def FtoC(f):
    #return fahrenheit to celsius
    return ((f-32)*5)/9
def CtoF(c):
    #return celsius to fahrenheit
    return ((9*c)/5)+32
    

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

Toncalculator-0.0.8.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file Toncalculator-0.0.8.tar.gz.

File metadata

  • Download URL: Toncalculator-0.0.8.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for Toncalculator-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0a1c3c18af30f647e1013c380b4863f6a3b403d605daf2a5172794054f4f728d
MD5 485c0ba3c88b8b7ff9b828de27a54f93
BLAKE2b-256 0101725309369e1f218af30d6f2877ac7992e3aa20d366ce292be4f542620a49

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