In: Computer Science
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to:
- Create a loop to iterate through each of the elements in the temperature list.
- Convert each element of this list to a Celsius temperature and then, for each valid temperature in the list, print out both the original Fahrenheit temperature and the Celsius equivalent in this format: "32 degrees Fahrenheit is equivalent with 0 degrees Celsius."
NOTE:
Be clear with indentation error while copying the code it may casuse indentaion error.
solution:
program 1: Create a loop to iterate through each of the elements
in the temperature list.
code:
Temperature=[56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]
print("creating loop to iterate over the list")
for i in Temperature:
print(i)
OUTPUT:
creating loop to iterate over the list
56.2
31.8
81.7
45.6
71.3
62.9
59.0
92.5
95.0
19.2
15.0
scrrenshot:
program 2: each element of this list to a Celsius temperature
and then,
for each valid temperature in the list,
print out both the original Fahrenheit temperature and the Celsius
equivalent in this format:
"32 degrees Fahrenheit is equivalent with 0 degrees Celsius."
code:
Temperature=[56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]
for i in Temperature:
c=(i-32)/1.8
print(i," degrees Fahrenheit is equivalent with ",c," degrees
Celsius")
OUTPUT:
56.2 degrees Fahrenheit is equivalent with 13.444444444444446
degrees Celsius
31.8 degrees Fahrenheit is equivalent with -0.11111111111111072
degrees Celsius
81.7 degrees Fahrenheit is equivalent with 27.61111111111111
degrees Celsius
45.6 degrees Fahrenheit is equivalent with 7.555555555555556
degrees Celsius
71.3 degrees Fahrenheit is equivalent with 21.833333333333332
degrees Celsius
62.9 degrees Fahrenheit is equivalent with 17.166666666666664
degrees Celsius
59.0 degrees Fahrenheit is equivalent with 15.0 degrees
Celsius
92.5 degrees Fahrenheit is equivalent with 33.61111111111111
degrees Celsius
95.0 degrees Fahrenheit is equivalent with 35.0 degrees
Celsius
19.2 degrees Fahrenheit is equivalent with -7.111111111111112
degrees Celsius
15.0 degrees Fahrenheit is equivalent with -9.444444444444445
degrees Celsius
scrrenshot: