Built-ins & Standard Library · Question 6 · Easy

math.floor is applied to a negative number and math.ceil to a positive one. What is printed?

import math

print(math.floor(-2.5), math.ceil(2.1))
  1. -2 3
  2. -3 3
  3. -3 2
  4. -2 2
Answer and explanation

Answer: B. -3 3

Explanation: floor goes to the next integer towards minus infinity, so −2.5 becomes −3, not −2. ceil goes upward, so 2.1 becomes 3.

Previous: isinstance is given a tuple of types in one call and a single type in the… · Next: enumerate is given start=1 while looping over two names. What does the loop…

Practise built-ins & standard library

Try a fresh set of built-ins & standard library questions with an explanation after every answer, free and without signing up: Built-ins & Standard Library practice. Or sit a full placement mock test.

More built-ins & standard library questions

More python practice

Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge