Celsius to Fahrenheit Table
Write a program that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit equivalents. The formula for converting a temperature from Celsius to Fahrenheit is
where F is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table.
Celsius to Fahrenheit Table program code:
#Print a table of the Celsius temperatures
#0 through 20 and their Fahrenheit
#equivalents.
print("Celsius\tFahrenheit")
print("-------------------")
#converting a temperature from
#Celsius to Fahrenheit
for celsius in range(0, 21):
fahrenheit = (9 / 5) * celsius + 32
#Display output
print(f"{celsius}\t\t\t\t{fahrenheit}")
Executed Output:
Celsius Fahrenheit
-------------------------
0 32.0
1 33.8
2 35.6
3 37.4
4 39.2
5 41.0
6 42.8
7 44.6
8 46.4
9 48.2
10 50.0
11 51.8
12 53.6
13 55.4
14 57.2
15 59.0
16 60.8
17 62.6
18 64.4
19 66.2
20 68.0