Python math Functions

By | July 22, 2019

Python math Functions – This Python tutorial will explain the use of Python math functions in Python Programs with example Python scripts and their output.

What is a Python math Module?

The Python programming language has a math module. The math module contains different functions for general math calculations.

What are different math functions?

There many math functions present in math module. For example, the math module contains the following functions:
sqrt() function
factorial() function
pow() function
exp() function
log() function
log10() function
sin() function
cos() function
tan() function
floor() function
ceil() function etc.

How we can use math module and its functions?

We must import the math module in our Python program. Then we can use math functions.

What is Python import statement?

import statement is used to import standard modules of Python.

For example to import math module, we will write import statement as follows:

import math

Use and Examples of  Math Functions

# This Python program show the use of
# different math functions present in
# Python math module. We first import
# math modue
# Author:
import math

c = math.ceil(7.4)

f = math.floor(7.4)

s = math.sqrt(25)

f = math.factorial(4)

p = pow(2,3)

a = abs(-5.50)

s = math.sin(0)

c = math.cos(0)

t = math.tan(0)
The output will be:
ciel(7.4)= 8
floor(7.4)= 7
sqrt(25)= 5.0
factorial(4)= 24
pow(2,3)= 8
abs(-5.50)= 5.5
sin(0)= 0.0
cos(0)= 1.0
tan(0)= 0.0

 1,632 total views,  2 views today

One thought on “Python math Functions

  1. Pingback: Python Functions Defining and Using Functions |

Leave a Reply

Your email address will not be published. Required fields are marked *