[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)


# 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```](https://pypi.org/project/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
```python
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:**
```python
result(add(1,2))

Output: 3
```
## Subtraction:
``` sub() ``` method is used to subtract 1st parameter by 2nd parameter. 
#### **Example:** 
```python
result(sub(2,1))

Output : 1  
```
## Multiplication:
``` mul() ``` methed is used to multiply two numberas.
#### **Example:** 
```python
result(mul(2,3))

Output : 6
```
## Division:
``` div() ``` method is used to divie 1st number by 2nd number.
#### **Example:** 
```python
result(dev(10,2))

Output : 5
```
## Squre:
``` square() ``` method is used to squire any numbers ```
#### **Example:** 
```python
result(square(2))

Output : 4
```
## To The Power:
``` power() ``` method is used as 2nd parameter to the power of 1st parameter.
#### **Example:** 
```python
result(power(2,4))

Output : 16
```
## Square Root:
``` sqroot() ``` method is used to square root a number.
#### **Example:** 
```python
result(sqroot(16))

Output : 4    
```
## Log:
``` log() ``` method returns the natural logarithm of a number, or the logarithm of number to base.
### Syntx:
```python
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:
```python
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:
```python
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:
```python
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:
```python
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:
``` python
# 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:
```python
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:
``` python
# 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:
```python
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:
``` python
# 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:
```python
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:
``` python
# 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:
```python
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:
``` python
# 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:
```python
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:
``` python
# 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:
```python
nCr(n,r)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| n | Required. Type integer |
| r | Required. Type integer |

```python
result(nCr(9,3))

Output : 84
```
# Mathmathical conversion

## Angle Conversions ##

## Dgree To Radian

`degTored()` method returns dgree to radian.

## Syntx
```python
degTored(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` dgree |

## Example
```python 
result(degTored(180))
 
Output : 3.1416   
```

## Radian To Dgree 

`redTodeg()` method returns radian to dgree.

## Syntx
```python
redTodeg(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` radian |

## Example
```python 
result(redTodeg(1))
 
Output : 57.297795
```

## Dgree To Minute

`degTomin()` method returns dgree to minute.

## Syntx
```python
degTomin(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` dgree |

## Example
```python
result(degTomin(1))

Output : 60
```

## Minute to Degree

`minTodeg()` method returns minute to dgree.

## Syntx
```python
minTodeg(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` minute |

## Example
```python
result(minTodeg(60))

Output : 1
```

## Degree to Second

`degTosec()` method returns dgree to second.

## Syntx
```python
degTosec(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` dgree |

## Example
```python
result(degTosec(1))

Output : 3600
```

## Second to Dgree

`secTomin()` method returns second to dgree.

## Syntx
```python
secTodeg(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` second |

## Example
```python
result(secTodeg(3600))

Output : 1
```

## Minute to Second

`minTosec()` method returns minute to second .

## Syntx
```python
minTosec(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` minute |

## Example
```python
result(minTosec(1))

Output : 60
```

## Second To Minute

`secTomin()` method returns second to minute.

## Syntx
```python
secTomin(x)
```

## Parameter Values:
| Parameter | Description |
| --- | --- |
| x | Required. `x` means `x` second |

## Example
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
result(ydTom(1))

Output : 1.0936132983377078
```

```python
def mileTokm(x):
    #return x mile to kilometre
    return x/0.621367
```
```python
def kmTomile(x):
    #return x kilometre to mile
    return x*0.621367
```
```python
def n_mileTom(x):
    #return x notical mile to meter
    return x*1852
```
```python
def mTon_mile(x):
    #return x meter to notical mile
    return x/1852
```
```python
def pcTokm(x):
    #return x parsec to kilometre
    return x*3.08567758128E+13
```
```python
def kmTopc(x):
    #return x kilometre to parsec
    return x/3.08567758128E+13
```
```python
## Area Conversions ##
def acreTomsq(x):
    #return x acre to squire meter
    return x/0.000247105
```
```python
def msqToacer(x):
    #return x squire meter to acre 
    return x*0.000247105
```
```python
## 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")
```
```python   
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")
```
```python    
## Mass Conversions ##
def ozTog(x):
    #return x ounces to grams
    return x*28.34952 
```
```python
def gTooz(x):
    #return x grams to ounces   
    return x/28.34952
```
```python
def lbTokg(x):
    #return x pounds to kilograms
    return x*0.45359237 
```
```python
def kgTolb(x):
    #return x kilograms to pounds
    return x/0.45359237 
```
```python
## Velocity Conversions ##
def kmphTomps(x):
    #return x kilometre/hour to meter/second
    m = x*1000
    s = 3600
    return m/s
```
```python
def mpsTokmph(x):
    #return x meter/second to kilometre/hour
    km = x/1000
    h = 1/3600
    return km/h
```
```python
## Pressure Conversions ##

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