- 1 Variables 2 Amount Float 3 Total Float 4 Choice Str 5 Asking The User For Their Choice 6 Choice Str In 1 (118.71 KiB) Viewed 53 times
1 #variables 2 amount = float() 3 total = float() 4 choice = str() 5 #Asking the user for their choice 6 choice = str(in
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1 #variables 2 amount = float() 3 total = float() 4 choice = str() 5 #Asking the user for their choice 6 choice = str(in
1 #variables 2 amount = float() 3 total = float() 4 choice = str() 5 #Asking the user for their choice 6 choice = str(input("Enter L for Large, M. for Medium, S. for small or Q:..")) 7 #looping to add up lawns cut 8 while choice !="Q": 9 ..if.choice == "L": amount = 40 elif choice == "M": ....amount = 25 ..else: 10 11 12 13 14 ....amount = 18 15 ...total. = total + amount 16 17 #printing the total 18 print("The total for cutting lawns: $", total) Collapse Review The program to your left has a few bugs in it. When running this program will ask the user to enter the size of the lawn they cut. If the user enters L (for Large), they made $40. If the user enters M (for Medium) they made $25 and if the user enters S (for Small) they made $18. The program will end when the user enters Q to quit. Once the user enters Q to quit, the program will print out the total that was made. If the user entered L, M and S followed by Q to quit, the program will output: The total for cutting lawns: $83.0 Fix the code. When done click on the Try It button to open the terminal and test your program. TRY IT If your program is not running, click on the Code Visualizer link to run your code line by line. If that still doesn't help, copy the code to either IDLE or VS Code in order to better debug this program. Code Visualizer