Math Functions - Coders PlayGround

Learn to code and change the future!

Tuesday, 29 August 2017

Math Functions


Hello friends, lets learn about the math functions of Python3



import math

a = 2
b = 5

print(a+b)
print(a-b)
print(a/b)
print(a*b)
print(a**b)
print("Value of pi: ", math.pi)
print("Ceil function",math.ceil(5.4))
print("Floor function",math.floor(5.4))
print("Absolute function",math.fabs(-5))
print("Factorial function",math.factorial(5))
print("Greates common divisor function",math.gcd(21,45))
print("Radian to degree function",math.degrees(30))
print("Degree to radian function",math.radians(30))

print("Complex no: ", "\n", "(3+5j) + (5 + 2j) = ",(3+5j) + (5 + 2j))


Output


Python supports other types of numbers, such as Decimal and Fraction. Python also has built-in support for complex numbers, and uses the j or J suffix to indicate the imaginary part (e.g. 3+5j).

There are many other functions such as log, trigonometric functions 

PropellerAds