Question: Recall that we wrote a program to convert from Fahrenheit to Celsius. Let's say we want to print out a table with the temperatures


Recall that we wrote a program to convert from Fahrenheit to Celsius.Let's say we want to print out a table with the temperatures

Recall that we wrote a program to convert from Fahrenheit to Celsius. Let's say we want to print out a table with the temperatures in Fahrenheit from 0 to 100 in steps of 10 along with their Celsius equivalents. First, we can write a function that converts from Fahrenheit to Celsius. The function has one parameter. The variable tempF represents the temperature in Fahrenheit. The function then uses that to compute the corresponding Celsius temperature. The last statement returns this result as its answer. Now we can write a program that uses this function, calling it with each Fahrenheit temperature from 0 to 100 in steps of 10. The formula for converting a temperature from Fahrenheit to Celsius : C = 5/9*(F-32) Hint; def f_to_c(tempF): #Convert fahrenheit temperature to celsius temperature tempC = return def main(): #Display "F print ( fahrenheit_temp = 0 while fahrenheit_temp C" #call the function f_to_c celsius_temp = # display fahrenheit temperature and celsius temperature. Format celsius temperature to 2 decimal places. print ( #Increment fahrenheit temperature by some value fahenheit_temp = #call the function main Output F 0 10 20 30 40 -17.78 -12.22 -6.67 -1.11 4.44 10.00 15.56 21.11 26.67 32.22 37.78 Partial coding 50 60 70 80 90 100 def main(): print ("Fahrenheit", "\t", "Celsius") for x in range(11): celsius_temp = f_to_c(x*10) print (x*10,"\t\t", "{:.2f}".format(celsius_temp)) def f_to_c(tempF): tempC = (5/9) * (tempF - 32) return tempC main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The python program to convert fahrenheit temperatur... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!