runtime
403 / 500
question 403 NumPy Foundations · easy

Fares to whole dollars

A summary chart groups taxi fares by whole dollars. Write whole_dollars(fares): return each fare rounded to the nearest whole number, as a list of int. Exact halves go to the even neighbour (2.5 → 2, 3.5 → 4), which is what np.rint and Python's round both do.

Functionwhole_dollars(fares)
faresa list of numbers (dollars and cents)
Returnsa list of int, one per fare, nearest whole number; [] for no fares
Examples
callwhole_dollars([40.8, 7.2, 17.5, 22.06])returns[41, 7, 18, 22]
callwhole_dollars([5.1])returns[5]
callwhole_dollars([])returns[]

Loading your progress…

Fares to whole dollars — Python practice · Runtime