0 of 6 problems solved • 0%

Exercise prompt

Reserve the Boats

The math module provides ceil, which rounds a number up to a whole integer. A partial boat still needs a reservation.

Example

An average of 2.01 hours exceeds a two-hour booking. Compare how two rounding functions treat that fraction.

from math import ceil, floor hours = 2.01 print(floor(hours), ceil(hours)) # 2 3 print(ceil(2.0)) # 2

Rounding up preserves an exact whole number. For the boat problem, first find the fractional number of loads.

Your task

Given a nonnegative number of people and positive capacity per boat, return the whole number of boats required. Use the imported ceil function.

boats_needed(11, 5) # 3