Which built-in function returns the absolute value of a number?
A
abs() B
fabs() C
math.abs() D
absolute()
Analysis & Theory
`abs()` is a built-in function that returns the absolute value of a number.
What is the output of `round(4.7)`?
A
4 B
5 C
4.7 D
Error
Analysis & Theory
`round()` rounds the number to the nearest integer; 4.7 becomes 5.
What is the result of `pow(2, 3)`?
A
6 B
8 C
9 D
5
Analysis & Theory
`pow(2, 3)` means 2 raised to the power of 3, which is 8.
Which module must be imported to use functions like `sqrt()` and `pi`?
A
statistics B
random C
math D
cmath
Analysis & Theory
The `math` module provides mathematical functions like `sqrt()` and constants like `pi`.
What does `math.floor(3.9)` return?
A
4 B
3 C
3.9 D
Error
Analysis & Theory
`math.floor()` rounds a float *down* to the nearest whole number.
What will this return?
import math
print(math.ceil(3.2))
A
3 B
4 C
3.2 D
Error
Analysis & Theory
`math.ceil()` rounds a float *up* to the nearest integer. 3.2 becomes 4.
Which constant from the `math` module represents π (pi)?
A
math.pie B
math.pi C
math.PI D
pi
Analysis & Theory
`math.pi` provides the value of π up to many decimal places.
What is the output of `min(3, 7, 2, 9)`?
A
2 B
3 C
7 D
9
Analysis & Theory
`min()` returns the smallest number among its arguments. Here, it's 2.
Which function returns the square root of a number in the `math` module?
A
sqrt() B
square() C
math.root() D
math.sqrt()
Analysis & Theory
The correct syntax is `math.sqrt(x)` after importing the `math` module.
What does `max(3, 9, 5, 6)` return?
A
3 B
6 C
9 D
5
Analysis & Theory
`max()` returns the highest value from the given arguments.