Question: Analyze the Python code written below. There are 3 errors. In the space below identify the line that contains the error, the type of error
Analyze the Python code written below. There are 3 errors. In the space below identify the line that contains the error, the type of error and how to fix it.
If you would like to copy and paste the code into IDLE you can. However, if you simply upload fixed code, you will not receive any credit for this question. In order to receive credit for this question you need to identify the line where the error occurs, the type of error and how you would fix it.
When running correctly this code is supposed to ask the user for the number of cookies they want to eat and number of cups of hot cocoa they wish to drink at a Winter Carnival. The program needs to then total those values, calculate the amount due and print them to the screen. The cost of one cookie is $1.50 and the cost of hot cocoa is $1. The program will stop asking for more cookies and hot cocoa when the user enters quit.
Your grade will be based on the following:
- What is causing the bug = 0.5 points
- What kind of bug is it? (logical, syntax, run-time) = 0.5 points
- How would you fix this bug? = 1 points
#Variables num_cocoa = int() num_cookies = int() total = float() answer = str() total_cookies = int() total_cocoa = int() while answer == "quit" num_cocoa = int(input("Enter the number of hot cocoas: ")) num_cookies = int(input("Enter the number of cookies: ")) total_cookies = total_cookies + num_cookies total_cocoa = total_cocoa + num_cocoa total = (total_cookies * 1.5) + (total_cocoa * 1.0) print("Total Cookies Ordered: ", total_cookies) print("Total Hot Cocoa Ordered: ", total_cocoa) print("Order Total: $", format(total, ',.2f')) Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
