Math Modules in Python

Math Modules in Python:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) ceil() The method ceil() returns the smallest whole number greater than or equal to x.

When you pass float values, it changes to integer values.

ceil math module in python 1

When you pass integer values, no changes take place.

python ceil math module

(2) floor() The floor() function returns the largest whole number less than or equal to x.

When you pass float values, it changes to integer values.

floor math module in python

When you pass integer values, no changes take place.

python floor math module

(3) fabs() The fabs() function returns the absolute value of the x.

Negative values change to positive.

fabs math module in python

Positive values remain positive.

python fabs math module

(4) factorial() The factorial() function return the x factorial as an integer. If you use float or negative value it gives you an error.

factorial math module in python

(5) fsum() The fsum() function returns an accurate floating point sum of values in the iterable.

python fsum math module

(6) sqrt() The sqrt() function returns the non-negative square root of x. If x is negative, a domain error occurs.

sqrt math module in python

(7) log() The log() function returns the natural logarithm of x. If x is negative, a domain error occurs. If x is zero, a range error may occur.

log function in python

How to Create a Program in Python (Using IDLE & Notepad)
How to Create Variables in Python
Google Search Console and Google Analytics
Operating System as a Resource Manager
Multimedia and Its Application
Information Security in E-Commerce
Mathematical functions– Python Docs

Comments (No)

Leave a Reply