In this tutorial we explain Python Tutorial – Mathematical Functions. In the above tutorial we shared video tutorial. Python includes the following functions that perform mathematical calculations.

Number abs() Method

The abs() method returns the absolute value og x i.e., the positive distance between x and zero.



x – This is a numeric expression

Number ceil() Method

The ceil() method returns the ceiling value of x i.e., the smallest integer not less than x.


import math

x – This is a numeric expression

Number floor() Method

The floor() method returns the floor of x i.e., the largest integer not greater than x.

import math

Number exp() Method

The exp() method returns exponential of x: e pow(x)

import math

Number max() Method

The max() method returns the largest of its arguments. i.e., the value closest to positive


Number min() Method

Returns the smallest of its arguments ie, the value closest to negative infinity.


Number pow() Method

Returns the value of x pow y

import math

Number round() Method

random() is a built-in function in Python.

It returns x rounded to n digits from decimal point.



Number sqrt() Method

The sqrt method return the square root of x for x>0.


import math

Let us see a simple program in Python using mathematical functions

Save it in desktop and run the code.

Random Number Functions

Random numbers are used for games, simulations testing and privacy applications.

Python includes the following functions that are commonly used.

Number choice() Method

Returns a random item from a list, tuple or string.

Number randrange() Method

Returns a randomly selected element from range(start,stop, step)
Number random() Method

Returns a random floating point number in the range[0.0,1.0]

Number seed() Mehod

initializes the basic random number generator.

Number shuffle() Method

Randomizes the items of a list in place.

Number uniform Method

Returns a random float r, such that x is less than or eqaul to r and r is less than y.

Let us see a program in Python using random() functions.

save it in desktop and run the code.

Trignometric Functions

Python includes the following functions

acos(), asin(), atan(), atan2(), cos(), hypot(), sin(), tan(), sin(), degrees() and radians().

Let us see a program in Python using Trignometric functions.

Save it in desktop and run the code.

This is about Number functions in Python.





A collection of source codes that I wrote in VB 6.0, ASP.NET, PHP, C#.NET, VB.NET and JAVA in a course of my career as web developer and software engineer that I would like to share to my fellow programmers. Some of the codes here is not my original work that I found over the Internet and Books while I'm learning how to program. I hope you find my work useful in your learning in programming. Please share my work to other people also who interested to learn the basics of web development and programming. Thank you very much and Happy Productive Programming Everyone. for more info please WhatsApp us on +91-9481545735 or Email id:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.