Question: l. You will fix a Python program that does the following: Collects the amount of a restaurant bill Collects the percentage (as a whole number)
l. You will fix a Python program that does the following:
- Collects the amount of a restaurant bill
- Collects the percentage (as a whole number) for a gratuity
- Collects the number of guests at the meal
- Calculates the total bill, plus the additional gratuity
- Calculates how much each person owes
- Responds with a message that contains the total bill amount and the amount each individual should pay
THIS PROGRAM DOES NOT WORK AS WRITTEN!
# # This Python program allows a user to input the amount of a restaurant bill, calculate the gratuity, and divide the bill among all attendees # # All calculations should be rounded to two decimal places #
input = bill_amount
gratuity = input("What percentage would you like to tip? ")) guests = input("How many guests are there?");
tip_amount = bill_amount * (gratuity/100) total_bill = round( bill_amount + tip_amount ) guest_bill = total_bill / guests print ("The total bill is [total_bill]. Each person owes $[guest_bill].")
ll. You will write a function that will convert Fahrenheit temperatures to Celsius.
Define a function named f_to_c with one parameter named f
The function should take the value of f (which represents degrees Fahrenheit) and convert it to its equivalent temperature in Celsius using this formula:
Celsius = (Fahrenheit-32) / 1.8
The last instruction of the function should be to return the temperature in Celsius.
Special Note: Rounding
Although you have a little bit of experience with the Python round() function, do not use it here. Your function should return the complete result of the calculation.
main() Function
You must define a main() function where you will call the f_to_c(f) function and pass the argument.
Your main() function should also print the returned value (the converted temperature) to the terminal
Hints
- Print only the result of the calculation. Do not add additional language or annotation
- Do not try to do any rounding
- You do not need to include error handling
Test Your Code
Use the button below to test your code with a value of 32 degrees Fahrenheit. The output should be 0.0
TEST CODE - 32 DEGREES F
Use the button below to test your code with a value of 212 degrees Fahrenheit. The output should be 100.0
TEST CODE - 212 DEGREES F
# Some code has been written for you. Do not modify the lines that are present.
# This line imports the "sys" module that allows our code to accept arguments from the command line. import sys
# This line creates a variable called "f_temp" that brings in the STRING VALUE (hint) of an argument from the command line. f_temp = sys.argv[1]
# Define your function here. # Return ONLY the result of the calculation with no rounding or additional language.
# Define your main() function # Your main() will do two things: # 1. Pass the value of the f_temp variable to the f_to_c(f) function # - Remember that the data type of "f_temp" is a STRING. # # 2. Print the returned value from the f_to_c(f) function WITH NO ADDITIONAL LANGUAGE
# Included here is the special language that runs your main() function by default. You do not need to modify anything below this line
if __name__== "__main__": main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
