Python : Math Module क्या होता है?

Python : Math module

पाइथन मे mathematical operation ( जैसे  trigonometric functions, representation functions, logarithmic functions आदि  ) को perform करने लिए math function का उपयोग किया जाता है |

Math function का उपयोग करने के लिए हमे math module को import करना पड़ता है क्योकि math module के अंदर सारे math function को define किया गया है।

पाइथन math module मे फंक्शन के साथ साथ कुछ mathematical constants को भी define किया गया है। जैसे ( PI , Euler number  आदि  )

Mathematical Constants in Python

 PI :  PI constant pi की value को return करता है |  ( value of PI : 3.141 )

Euler Number :   ( value of Euler Number : 2.7182 )

Python Math Function

python मे math module के अंदर बहुत सारे फंक्शन होते है इनका उपयोग  mathematical operation मे किया जाता है।  इन फंक्शन को अलग अलग category मे रखा गया है |

Power and logarithmic functions exp() , expm1() , log () , log1p() , log2() , log10() , pow () ,sqrt())

Trigonometric function ( acos() , asin() , atan() , atan2() , dist() , hypot() , cos() , sin() , tan () )

Hyperbolic functions ( acosh() , asinh() , atanh() , cosh() , sinh() , tanh() )

Number-theoretic and representation functions ( ceil () , comb() , copysign() , fabs() , factorial() , floor () , fmod() , fsum() , gcd() , isclose() , isfinite() , isinf() , isqrt() , isnan(), modf() , idexp() , perm() , prod () , remainder() , trunc()  )

Angular conversion degree() , radians() )

Power and logarithmic functions

pow : math.pow () function किसी नंबर के पॉवर को return करता है।

SYNTAX : math.pow(x, y)     
दिए गए syntax मे X एक वैल्यू है और Y , X की की पॉवर है।
अतः pow () फंक्शन हमे x ** y return करेगा। 

Source Code :
import math 
print(math.pow(5, 2)) 
print(math.pow(8, 3))

#OUTPUT
25.0 
512.0

sqrt() : math.sqrt() function किसी नंबर का square root return  को  करता है।

SYNTAX : math.sqrt(x)
Source Code :
import math

print(math.sqrt(9))
print(math.sqrt(16.16))

#OUTPUT
3.0
4.019950248448356

log () :  math.log( ) function दिए हुए नंबर का natural logarithm return करता है यह base (e) से calculate की जाती है।

SYNTAX : math.log(x, base)
X: दिए गए syntax मे X एक +ve वैल्यू  है |
base : logarithm का base होता है | तथा यह Optional होता है |(logbasex )

Source Code :
import math
print(math.log(6.5, 3))
print(math.log(4,))

#OUTPUT
1.703787765901335
1.3862943611198906

log10() :   math.log10( ) function दिए हुए नंबर का base logarithm return करता है  |

SYNTAX : math.log10(x)
Source Code :
import math
print(math.log10(5.5))

#OUTPUT
0.7403626894942439
 Python math module : Trigonometric function
 Python math module : Number-theoretic and representation functions