What will be the results of math.floor(4.7) and math.ceil(4.7) respectively ?

2026

What will be the results of math.floor(4.7) and math.ceil(4.7) respectively ?

  1. A.

    5 and 4

  2. B.

    4 and 5

  3. C.

    4.0 and 4.0

  4. D.

    5.0 and 5.0

Attempted by 223 students.

Show answer & explanation

Correct answer: B

The math.floor() function rounds a number down to the nearest integer, so math.floor(4.7) equals 4. The math.ceil() function rounds a number up to the nearest integer, so math.ceil(4.7) equals 5.

Explore the full course: Rssb Senior Computer Instructor