runtime
491 / 500
question 491 Production Readiness Capstone · easy

The tip percentage of a trip

The report's core needs one small, pure calculation: the tip as a percentage of the fare. TLC data includes zero and negative fares (refunds and adjustments), which must not produce a percentage.

Functiontip_percentage(trip); trip has fare_amount and tip_amount
Returnstip_amount / fare_amount * 100 rounded to 1 decimal place; None when the fare is 0 or less
Rulethe trip is not changed
Examples
calltip_percentage({'trip_id': 16126, 'fare_amount': 40.8, 'tip_amount': 10.7})returns26.2
calltip_percentage({'trip_id': 16128, 'fare_amount': 17.2, 'tip_amount': 0})returns0.0
calltip_percentage({'trip_id': 16130, 'fare_amount': 5.1, 'tip_amount': 1})returns19.6

Loading your progress…

The tip percentage of a trip — Python practice · Runtime