226k views
4 votes
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

F = 9/5 × C + 32
where F is the Fahrenheit temperature, and C is the Celsius temperature. Your program must use a loop to display the table.

1 Answer

2 votes

Final answer:

A loop-based program in Python can display a table of Celsius temperatures from 0 to 20 and their Fahrenheit equivalents using the formula F = (9/5) × C + 32 for each iteration.

Step-by-step explanation:

Program for Temperature Conversion

To create a program that displays a table of Celsius temperatures from 0 to 20 and their Fahrenheit equivalents, you will need to use a loop to calculate the Fahrenheit temperature for each Celsius temperature. Here's an example in Python:

for C in range(21):
F = (9/5) * C + 32
print(f'{C} Celsius is equivalent to {F} Fahrenheit')

This loop runs 21 times, each time calculating the Fahrenheit equivalent of the current Celsius temperature. The formula F = (9/5) × C + 32 is used for converting temperatures from Celsius to Fahrenheit. The resulting table lists all Celsius values from 0 to 20 alongside their Fahrenheit counterparts.

User Andrii Tsok
by
8.3k points