Question

In: Computer Science

Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt...

  1. Create a new file name condition_quiz.py.

  2. Add a comment with your name and the date.

  3. Prompt the user to enter the cost. Convert the input to a float.

  4. Prompt the user for a status. Convert the status to an integer

  5. Compute the special_fee based on the status.

If the status is 0, the special_fee will be 0.03 of the cost.

Else if the status is 1, the special_fee will be 0.04 of the cost.

Else if the status is 2, the special_fee will be 0.06 of the cost.

Else if the status is 3 or 4, the special_fee, the special_fee will be 0.07 of the cost.

Otherwise, the special_fee will be 0.10 of the cost.

  1. Compute the total_cost as the cost plus the special_fee. Print out the total_cost with two decimal places of precision.

Solutions

Expert Solution

Solution:-

Since there is no name specified so the comment in the code has been left empty.

Python 3 Code:-

# Name :
# Date : 8 October 2020

# Prompt the user to enter the cost
cost = float(input('Enter the cost: '))
# Prompt the user for a status
status = int(input('Enter the status: '))
# In case status is 0
if status == 0:
special_fee = 0.03 * cost
# In case status is 1
elif status == 1:
special_fee = 0.04 * cost
# In case status is 2
elif status == 2:
special_fee = 0.06 * cost
# In case status is 3 or 4
elif status == 3 or status == 4:
special_fee = 0.07 * cost
# Otherwise
else:
special_fee = 0.10 * cost
# Computing total cost   
total_cost = cost + special_fee
# Printing total cost with two decimal places precision
print('Total cost: %.2f'%total_cost)

Code snapshot:-


Output snapshot:-


Related Solutions

python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create a variable named base_fee and set the value to 5.5. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone. Convert the zone to an integer. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the...
2. Add a title comment block to the top of the new Python file using the...
2. Add a title comment block to the top of the new Python file using the following form # A brief description of the project 3. Ask user - to enter the charge for food 4. Ask user - to enter theTip for server ( remember this is a percentage , the input therefore should be decimal. For example, for a 15% tip, 0.15 should be entered) 5. Ask user - to enter the Tax amount ( this is a...
Add an item to a Text File / C++ the program will prompt for a filename...
Add an item to a Text File / C++ the program will prompt for a filename AND then prompt for a text file item. text file items always contain an unknown amount of spaces, (see getline). Allow the user to put both the filename and the extensions, like groceries.txt or retirementToDo.clist Don't add any directory information to the filenames, use them as typed. If the file does exist, the item will be APPENDED to the end of the file. If...
(previous program) Prompt the user for the filename. Create a new file object sensehat_data_file which opens...
(previous program) Prompt the user for the filename. Create a new file object sensehat_data_file which opens the file in write mode. Write a loop which will read in 20 values for temperature and humidity from the SenseHat. Sleep 0.5 seconds between each reading taken from the SenseHat Write out the temperature and humidity to the file sensehat_data_file, separated by a comma. Close the file.) ONLY ANWSER problem below Then Open the file in read only mode. Use a loop to...
Name your source code file sh.c Write your own simple shell. Your shell should prompt the...
Name your source code file sh.c Write your own simple shell. Your shell should prompt the user for a command, run it, then prompt the user for their next command. If the user types "exit", then the shell should terminate. The shell should ignore Ctrl-C. Inside the attached parse.h header file, there is a parse function that you can use to split up the command line into separate strings. Recall that execvp accepts two arguments: the name of the command,...
HW_6a - Read a text file Create a new C++ project and name it as:   Numbers...
HW_6a - Read a text file Create a new C++ project and name it as:   Numbers Create a text file and     save it as:   data.txt Create and save the file      in a C++ project      in the Resource folder. Enter the following numbers:        3                                                              4                                                              5       Note:   After you enter the 5, don’t press the enter key. Save and close the file. Add another file and name it:   Source.cpp Write one statement that declares a file...
Create a program that will prompt me for each of the following items: 1. Date of...
Create a program that will prompt me for each of the following items: 1. Date of Birth 2. Typical wake up time 3. Next Dentist Appointment. ( Date and Time) Create a Date structure and a method to load and return the date structure. Create a Time-of-day structure and a method to load and return the Time-of-day structure. Create a DateTime structure that includes the Date and Time-Of-Day structure. The Date structure should include year, month, day. The Time-of-day structure...
C++ Start with your Date class in the Date.cpp file (from Date01B assignment or whatever) Name...
C++ Start with your Date class in the Date.cpp file (from Date01B assignment or whatever) Name the new Date file Date03.cpp Add the following constructors to the date class create a constructor that takes 3 integers in the order month, day, year assigns the month, day, year parameters to the corresponding data items. Use the ‘setter’ to assign the values Add a line cout << “in constructor with 3 ints\n” in the constructor a 'default' constructor - no arguments Add...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT