Solution Exercise 41

Write a list comprehension that creates a list of tuples. Each tuple has two values, a temperature in Farenheit and a temperature in Celsius.

Create one list for Farenheit values from 0 to 100 in steps of 5 and the matching Celsius values.

Create another list for Celsius values from -10 to 50 in steps of 2 and the matching Farenheit values.

Hint:
The conversion formulas between °F and °C are:

°C = (°F - 32) × 5/9
°F = °C × 9/5 + 32


def main():
    F = [(f,(f-32)* 5/9) for f in range(0,101,5)]

    #Code above is the same as below
    F = []
    for f in range(0,101,5):
        t = (f,(f-32)* 5/9)
        F.append(t)
    
    C = [(c,c * 9/5 + 32) for c in range(-10,51,2)]
    print(F)
    print(C)

if __name__ == '__main__':
    main()