You’re also going to need a rental car in order for you to get around.
def finish_game(score): tickets = 10 * score if score >= 10: tickets += 50 elif score >= 7: tickets += 20 return tickets
In the above example, we first give the player 10 tickets for every point that the player scored. Then, we check the value of
score multiple times.
- First, we check if
scoreis greater than or equal to 10. If it is, we give the player 50 bonus tickets.
scoreis just greater than or equal to 7, we give the player 20 bonus tickets.
- At the end, we return the total number of tickets earned by the player.
Remember that an
elif statement is only checked if all preceding
if/elif statements fail.
Below your existing code, define a function called
rental_car_cost with an argument called
Calculate the cost of renting the car:
- Every day you rent the car costs $40.
ifyou rent the car for 7 or more days, you get $50 off your total.
- Alternatively (
elif), if you rent the car for 3 or more days, you get $20 off your total.
- You cannot get both of the above discounts.
Return that cost.
Just like in the example above, this check becomes simpler if you make the 7-day check an
if statement and the 3-day check an