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

pow(x,y)returns power,x is a base,y is exponentpow(4,6) #4096
abs(x)returns absolute value of x(non negative)abs(-3.2) #3.2
math.sin(x)returns sin value of xmath.sin(33) #0.9999118601072672
math.cos(x)returns cos value of xmath.cos(33) #-0.013276747223059479
math.factorial(x)returns factorial of xmath.factorial(5) #120
math.ceil(x)Returns smallest integer greater than or equal to xmath.ceil(5.54) #6
math.sqrt(n)returns square root of xmath.sqrt(16) #4
math.log(n)returns log value of xmath.log(16) #2.772588722239781
Last updated on by vishal devxo