June 8, 2022By

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.

Math Module

  • 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°

Math Module

Output is as below :

Math Module

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

Math Module

Output is as below :

Math Module    

 

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.

Math Module

Output is : 

Math Module

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

Math Module

Output is:

Math Module

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

 Math Module

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

Math Module

Output is: 

Math Module

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

Math Module

Output is :

  Math Module

 

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)

Math Module

Output is :

Math Module

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

Math Module

Output is :

    Math Module
 

For Free, Demo classes Call: 02071171500
Registration Link: Click Here!
 

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

 

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.

Math Module

Output is :

    Math Module 

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

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

Math Module

Output is :

Math Module

 

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.

Math Module

Output is :

Math Module

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.

Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.

All articles by Shahaji Chinchole

#Technology#Education#Career Guidance