Lesson 2. Integer and float numbers
7/10. Math module
Python has a ton of functions for calculations with floats. Most of them can be found in themath
module.To use this module, you need to import it first by writing the following instruction at the beginning of your program:
import mathFor example, if we want to find the ceiling value for
x
— the smallest integer not less than
x
— we call the corresponding function from the math module: math.ceil(x)
.
Instructions
Click "Run" to see what happens in output!
import math x = math.ceil(4.2) print(x) print(math.ceil(1 + 3.8))