Quick actions

cmd+k|ctrl+k

Navigation

Languages

21-May-2026 Lesson 10 (Additional 1) (Page 92)

Snippet info

Language

Python

Visibility

public

Author

michaelluiwaihung

Created

2026-05-21T13:02:22.934349Z

Updated

2026-05-24T13:07:37.472205Z

#https://glot.io/snippets/hc7676ukim

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