Number 9 using Python programming
A car’s miles-per-gallon (MPG) can be calculated with the following formula: Write a program that asks the user for the number of miles driven and t MPG Miles driven Gallons of gas used used. It should calculate the car’s MPG and display the result. 8. Tip, Tax, and Total Write a program that calculates the total amount of a meal purchase program should ask the user to enter the charge for the food, and then calculate the gallons of ga d at a restaurant. The the amount of a 1 8 percent tip and 7 percent sales tax. Display each of these amounts and the total 9. Celsius to Fahrenheit Temperature Converter Write a program that converts Celsius temperatures to Fahrenheit temperatures. l is as follows: F=3-32 The program should ask the user to enter a temperature in Celsius, and then display the temperature converted to Fahrenheit. 10. Ingredient Adjuster A cookie recipe calls for the following ingredients: . 1.5 cups of sugar . 1 cup of butter . 2.75 cups of flour The recipe produces 48 cookies with this amount of the ingredients. Write a pro asks the user how many cookies he or she wants to make, and then displays te a program that
Expert Answer
temperature = input(“Enter the temperature you want to convert? (for example 40F, 120C etc.) : “)
deg = int(temperature[:-1])
a_conv = temperature[-1]
if a_conv.upper() == “C”:
result = int(round((9 * deg) / 5 + 32))
c_conv = “Fahrenheit”
elif a_conv.upper() == “F”:
result = int(round((deg – 32) * 5 / 9))
c_conv = “Celsius”
else:
print(“Input proper convention.”)
quit()
print(“The temperature in”, c_conv, “is”, result, “degrees.”)