Math Module

  • By
  • June 8, 2022
  • Python
Math Module

What is math Module ?

For mathematical operations like trigonometric operation, logarithmic operation, angle conversion, etc. python has a built-in standard module which is known as math module. You can use this module by using import math.

  • Some standard math modules are:
    • Angle Conversion Operation
    • Trigonometric Operation 
    • Logarithmic Operation
    • Basic Mathematical Operations
    • Mathematics Constants

For Free, Demo classes Call: 02071171500

Registration Link: Click Here!

 

  • Angle Conversion Operation :
    • Conversion of degree to radian or vice versa.
    • math.degrees() – This method is used for conversion of angle in radians to angle in degrees : – 3.1416 rad = 180°

Output is as below :

  • math.radians() – This method is used for conversion of angle in degrees to angle in radians : 180° = 3.14159 rad

Output is as below :

    

  • Trigonometric operation : 
    • This operation is used to find out sine, cosine or tangent value of a number.
    • This module by default took angle parameter value in radians.
    • So if you have angle in degree unit, first convert it in radian unit by using math.radians() method.

 

  • math.cos() – It gives cosine value of  number or of an angle in radians.

Output is :

      

  • math.sin() –  It gives sine value of  number or of an angle in radians.

Output is:

       

  • math.tan() – It gives tangent value of  number or of an angle in radians.

Output is :

  • math.cosh() – It gives hyperbolic cosine value of  number or of an angle in radians.

 

Output is :

       

 

  • math.sinh() –  It gives hyperbolic sine value of  number or of an angle in radians.

 

Output is:

       

  • math.tanh() – It gives hyperbolic tangent value of  number or of an angle in radians.

 

Output is :

 

  • Logarithmic Operation:
    • This operation is used to find out logarithmic values of parameters
    • math.log() – It gives the natural logarithm of a number. – loge(x) or ln(x)

Output is :

    

  • math.log(x,y) – It gives the logarithmic value of ‘x’ parameter with base ‘y’. – logy(x)

Output is :

   

For Free, Demo classes Call: 02071171500

Registration Link: Click Here!

 

  • math.log10() – It gives logarithmic value of a number with base-10. – log10()

Output is :

  • math.log2() – It gives logarithmic value of  a number with base-2. – log2()

Output is :

  • Basic Mathematical Operation :

 

  • Mathematical operations like square root, factorial, absolute, reminder, round-up, power, etc.

 

  • math.ceil() – It round up the number upward to  nearest integer.

Output is :

     

 

  • math.floor() – It round up the number downward to nearest integer.

Output is :

    

  • math.fabs() – It gives absolute value of the number.

Output is :

    

  •  math.factorial() – It gives factorial value of the number.

Output is :

  • math.fmod(x,y) – It gives reminder of  x/y value.

Output is :

  •  math.pow(x,y) – It gives ‘x’ raised to the power of ‘y’.

Output is :

  • math.gcd(x,y) – It gives greatest common divisor of x & y.

Output is :

  • Mathematics Constants :
    • The well-known mathematics constant is pi (π)
    • The ratio of  circumference of a circle to the  diameter of  that circle is ‘pi’ constant.
    • Mathematically it is calculated as  22/7 = 3.14159

 

  • math.pi It gives value of ‘pi’ constant.

Output is :

Note:- If  you need more methods in math module in python refer following link:

For Free, Demo classes Call: 02071171500

Registration Link: Click Here!

 

Author:-

Shahaji Chinchole

Call the Trainer and Book your free demo Class  Call now!!!
| SevenMentor Pvt Ltd.

© Copyright 2021 | Sevenmentor Pvt Ltd.

 

 

Submit Comment

Your email address will not be published.

*
*