133. Python Program to Calculate a Bill with a Default Tip
MediumArguments
Overview
A default value makes a parameter optional. Call the same function with and without it.
Problem Statement
Write a function show_bill(amount, tip=10) that adds tip percent to amount and prints the total with two decimals, like this:
Bill with 10% tip: 550.00
Then read the bill amount (a number, maybe with decimals) and a tip percent (a whole number), one per line. Call the function twice:
- With only the amount, so the default tip of 10 is used.
- With the amount and the tip you read.
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value per line, in this order: the amount, then the tip percent. Example:
500
15
Output
The output for that example:
Bill with 10% tip: 550.00
Bill with 15% tip: 575.00
The tests try 4 different inputs.