Python Math Built-in Module Overview

Python me Math module bhi ek tarah ka built-in module hai, jo Mathematics se related functions ko handle karta hai. Jaise trigonometric functions, representation functions, logarithmic functions, etc.

Math Module ko import kaise kare?

Python me Math module ko import karne ka simple method hai, just write :

>>> import math

List of operations through Math Module:

math.pi

import math
y = math.pi
print(y)

math.exp()

math.exp() base value ke according exponential value return karega.

import math
num= 5e-2 
print(‘The number (x) is :’, num)
print(‘e^x (using exp() function) is :’, math.exp(num)-1)

math.fabs()

Yah function sirf absolute value yani ki sirf positive value return karega. 

import math
num = math.fabs(-12.565)
num2 = math.fabs(45.67)
print(num)
print(num2)

math.log()

math.log() natural logarithmic value return karega

import math
num = 2e-8
print(math.log(math.fabs(num),10))

math.log10()

math.log10() kisi bhi number ko logarithmic value (base 10) me convert karke output return karega.

import math
y = math.log10(x)
print(y)

math.pow(x,y)

math.pow(x,y) x aur y ke value ke hisab se  value return karega. jaha first argument i.e. x base value hai aur second argument ‘y’ ek powered index hai.

import math
x = 4
y = 3
z = math.pow(x,y)
print(z)

math.ceil()

math.ceil() function diye gaye value ka expected greater or equal value return karta hai. Example se samajhte hain :

import math
x = 12.54
print(math.ceil(x))
y = 13.00
print(math.ceil(y))

math.floor()

math.floor() function math.ceil() function ka poora opposite hai, means yah diye gaye value ka expected lesser or equal value return karta hai.

import math
x = 12.54
print(math.floor(x))
y = 13.00
print(math.floor(y))

math.factorial()

Factorial function ko aap ache se jante hoge, aur yah math.factorial() function kisi bhi value ka factorial calculate karta hai. jaise fact(4) = 4 x 3 x 2 x1 = 24

import math
x = 4
y = math.factorial(x)
print(y)