Quick actions

cmd+k|ctrl+k

Navigation

Languages

Thermometer exercise

Snippet info

Language

Python

Visibility

public

Author

tonyngswell

Created

2026-05-21T13:00:23.130191Z

Updated

2026-05-21T13:00:23.130191Z

i = 1
while i <=5:
    print('Count:',i)
    c = input("Please select 1 (C) or 2 (F) :")
    t = input("input temperature :")
    if c.isdigit() and t.isdigit():
        cint = int(c)
        tinit = int(t)
        if cint == 1:
            c_to_f = 9/5 * tinit + 32
            print(f'Celsius {tinit} degree = Fahrenheit {c_to_f} degree')
        elif cint == 2:
            f_to_c = (tinit - 32) * 5/9
            print(f"F {tinit} = Celsius {f_to_c} degree")
        else:
            print("Please input 1 or 2 only")
    else:
        print("No input or the input are not digits")
    i += 1    
INFO