Lesson 7.7
The math module has ready-made mathematical operations:
| Call | What it gives |
|---|---|
math.sqrt(16) |
the root — 4.0 |
math.pi |
the number π (no brackets) |
math.ceil(4.2) |
rounds up — 5 |
math.floor(4.8) |
rounds down — 4 |
The root of a negative number raises an error: there is a separate module for those numbers.
The check sets the numbers a and b and a decimal value. Print, in order:
math.sqrt(a ** 2 + b ** 2);π;value rounded up — with math.ceil;value rounded down — with math.floor.math.sqrt(...) is the root, math.ceil rounds up, math.floor rounds down.
A square is ** 2. Build the sum of the squared legs inside sqrt.
Print the constant math.pi on its own line, as it is.