Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 4: Fix the Errors The program below has 3 errors in it. Fix this program so that it runs without errors. When running it

image text in transcribed image text in transcribed image text in transcribed
image text in transcribed
Exercise 4: Fix the Errors The program below has 3 errors in it. Fix this program so that it runs without errors. When running it will ask the user how many people are going to a theme park and for how many days. The program will then determine the total amount for the trip. There is a discount when the trip is planned over many days. For instance the price for 1 day is $40 per day. For 2 days the price per day is $35. If the user wants to spend 3 days in the park the price is per day. Given the user has 4 people in their party and will be in the park 2 days, the program should print the following: Price per day: $35 Total for your trip: $280 To test your code before grading, click on the Try It button. To run your code line by line, click on the Code Visualizer. Codio will test your program using 4 people and 2 days. The second test will use different data. Ff This program calculates the totol cost of a thewe park trip 8 based on the number of people and the number of days spent in the park. people = int (input ( "How many people are going to the theme park? ")) * ask user for number of people days = int (input ( "For how many days will you be visiting the park? ")) * ask user for number of days If days an 1: "Fixing the error, it should be comparison oporator ".=" instead of assygnment operator '.' price per day =40 - set the price per day to $4. elif days: =2 : If the number of days is 2 price per day =35 - set the price per day to $35 else: * If the number of days is more than ? price per day =30 * set the price per day to $30 total price = people * price per day * days " calculate the total price by multiplying the number of people by the price per day and the number of days: print ("Price per day: \$" str (price per day)) Fr print the price per day print ("Total for your trip: $+ str (total price)) * print the total price IndentationError: unexpected indent codiocmatchcadet-chariotinvest: //workspace\$ python3 Content/error4.py File "Content/error4.py", line 14 price =$40 Syntaxerror: invalid syntax codicematchcadet-chariotinvest:-/workspace\$ python3 Content/error4.py How many people are going to the thene park? python3 Content/error4.py Traceback (most recent call last): File "Content/error4.py", line 9, in \&nodules people = int (input ("How many people are going to the theme park? ")) ValueError: invalid literal for int() with base 10: 'python3 Content/error4.py' codiognatchcadet-chariotinvest:-/workspaces python3 Content/error4.py File "Content/error4.py", line 9 price per_day =40 SyntaxError: invalid syntax codio@matchcadet-chariotinvest:-/workspace\$ python3 Content/error4.py File "Content/error4.py", Line 9 price per_day =40 Output: File "Content/error4.py", line 9 days = int(input("Enter number of days you will be in the park: ")) IndentationError: unexpected indent Expected: Enter the number of days you will be in the park: Enter the number of people in your party: Price per day: $35 Total for your trip: $280 Feedback: Make sure you have identified and fixed all 3 errors. Check 2 failed Output: File "content/error4.py", line 9 days = int(input("Enter number of days you will be in the park: ")) IndentationError: unexpected indent Expected: Enter the number of days you will be in the park: Enter the number of people in your party: Price per day: $40 Total for youn trip: $200

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

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Question Can plan participants borrow from a VEBA?

Answered: 1 week ago

Question

Question What is an educational benefit trust and how is it used?

Answered: 1 week ago