Mathematics with Python

We learnt about modules in the previous blog. In this blog ,we use a built in module called math to do mathematical operations.

The entire list of function in math module is given in math module functions.

To use the math module , you need to use import keyword. The statement is written as:

import math 

Let us now play with some functions in the math module.


As seen above, math.ceil rounds the number to next value. math.floor rounds number to previous value. math.copysign copies sign of second value to first value and returns first value. math.factorial computes factorial of a number. math.trunc truncates the decimal part of the number. math.exp,math.log10,math.pow,math.sqrt,math.cos,math.sin return the exponential,log value, power,square root ,cosine and sine values of the number. math.pi and math.e are the constants pi and e.

The math module is used for number theoretic and representation function like math.ceil, power and logarithmic functions like math.exp, trigonometric functions like math.sin,angular conversion functions ,hyperbolic functions and for certain special functions and constants like pi and e.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: