Variables in Python
normally we all know common mathematics like Addition, Subtraction, Multiplication, Division, Modulo, Power. some common basic examples are given below.
5+6 #11(addition)
5-2 #3( Subtraction )
4*2 #8( Multiplication )
10/ 2 #5(division)
11/2 #1(remainder modulo divsion)
2**3 #8(power)
apart from all these common mathematics,there are trigonometric ,quadratic,measurements and a lot ,to use all these we should use math library ,to use math library functions ,first we need to import library into our program
import math
by using about code,you can use any math function in your program ,some examples are given below
Function | description | Example |
---|---|---|
pow(x,y) | returns power,x is a base,y is exponent | pow(4,6) #4096 |
abs(x) | returns absolute value of x(non negative) | abs(-3.2) #3.2 |
math.sin(x) | returns sin value of x | math.sin(33) #0.9999118601072672 |
math.cos(x) | returns cos value of x | math.cos(33) #-0.013276747223059479 |
math.factorial(x) | returns factorial of x | math.factorial(5) #120 |
math.ceil(x) | Returns smallest integer greater than or equal to x | math.ceil(5.54) #6 |
math.sqrt(n) | returns square root of x | math.sqrt(16) #4 |
math.log(n) | returns log value of x | math.log(16) #2.772588722239781 |