Python Mathematical Function

Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!

Python has many inbuilt function.

Method Description
round(number[, ndigits])  rounds the number, you can also specify precision in the second argument
pow(a, b) Returns a raise to the power of b
abs(x) Return absolute value of x
max(x1, x2, …, xn) Returns largest value among supplied arguments
min(x1, x2, …, xn) Returns smallest value among supplied arguments

Below mentioned functions are in math  module, so you need to import math module first, using the following line.

Method Description
ceil(x) This function rounds the number up and returns its nearest integer
floor(x) This function rounds the down up and returns its nearest integer
sqrt(x) Returns the square root of the number
sin(x) Returns sin of x where x is in radian
cos(x) Returns cosine of x where x is in radian
tan(x) Returns tangent of x where x is in radian

Let’s take some examples to understand better

In next post we will learn how to generate random numbers in python.

Other Tutorials

This site generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!

Leave a Reply

2 Comments on "Python Mathematical Function"

Notify of
avatar

Sort by:   newest | oldest | most voted
Jody DeRidder
Guest
Jody DeRidder
2 years 6 days ago

you have a series of errors here. Absolute of -22 is 22. Max of that sequence is 81. Min of the next sequence is 12.
8**2 is 64. The 1st round should be 5. You’re going to confuse people with these examples.

wpDiscuz