Running a python program, input, output and variables
Using what you know about python so far, complete the program described below.
Check the class slides and your textbook for reference.
First things first, make sure your Python environment is working and that you can write and run a program.
Write a program that gets a meal subtotal from the user and prints tip amounts for four different percentages, as shown below.
Note that making it prettier requires a few more advanced things than print()
, so don't worry about it right now.
Subtotal? 15.67 ---------------- 12.0 % tip: $ 1.8803999999999998 ($ 17.550400000000003 total) 15.0 % tip: $ 2.3505 ($ 18.0205 total) 18.0 % tip: $ 2.8205999999999998 ($ 18.4906 total) 20.0 % tip: $ 3.1340000000000003 ($ 18.804 total) ----------------
Here it is cleaned up using string formatting. If you want to do that (totally optional!), look it up here (use the new style).
Subtotal? 15.56 ---------------- 12% tip: $1.87 ($17.43) 15% tip: $2.33 ($17.89) 18% tip: $2.80 ($18.36) 20% tip: $3.11 ($18.67)