Analyze the following Python code snippet and identify the correct output…
2026
Analyze the following Python code snippet and identify the correct output produced by the program from the given options:
from math import ceil, pi
print(ceil(-pi))
- A.
-3
- B.
-4
- C.
4
- D.
The code raises an error
Attempted by 437 students.
Show answer & explanation
Correct answer: A
pi ≈ 3.14159So,
-pi ≈ -3.14159ceil(x)returns the smallest integer ≥ x
ceil(-3.14159) = -3