Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3: Identify & Fix the Error Analyze the code to your left. It contains three errors. Identify this type of error and fix the

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Exercise 3: Identify \& Fix the Error Analyze the code to your left. It contains three errors. Identify this type of error and fix the code. When running correctly, the program will determine the price for each doughnut based on the quantity they want to buy. Once a price has been deteremined the program will calculate the subtotal, tax and total for the order. If the user enters 6 for the number of doughnuts, the program should print: Subtotal: $9.8 Tax: $0.54 Total: $9.54 To test your code before grading. click on the Try It button. To run your code line by line, click on the Code Visualizer. What type of error is this? In the space provided enter syntax, run-time or logic. To test your code prior to grading, click on the Code Visualizer button. When you have fixed the code click on the Check Itl button. Codio will run your program twice. The first test will use 6 for the number of doughnuts. The second test will use another type of input. x Check 1 failed output: File "Content/error3.py", line 28 print ( "Tax: $ ", , tax) Syntaxerror: invalid character in identifier Expected: Enter the number of doughnuts: Subtotal: $9.0 Tax: \$ 0.54 Total: $9.54 Feedback: Make sure you have identified all 3 errors. Check 2 failed Output: File "Content/error3.py", line 28 print ( "Tax: \( \$ ", \operatorname{tax} \)quot;,tax ) Syntaxerror: invalid character in identifier Expected: Enter the number of doughnuts: Subtotal: $4.5 Tax: $0.27 Total: \$4.77 price=float ( ) subtotal=float () tax=float ( ) total=float ( ) \#Ask user for the number of num doughnuts num_doughnuts=int (input ( "Enter the number of doughnuts:" )) aDetermine price for each doughnut if num_doughnuts =6 : price =1.5 elif num_doughnuts =8 : "First error, we have to use "elif" not "if". This is a semantic error (Logical erro price =1.250 elif num_doughnuts

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions