Quick actions

cmd+k|ctrl+k

Navigation

Languages

ERB 28 Jan 2026 Exercise Celsius

Snippet info

Language

Python

Visibility

public

Author

michael-wong

Created

2026-01-29T14:22:37.705361Z

Updated

2026-01-29T14:22:37.705361Z

temp = input("Please select 1 (Celsius) or 2 (Fahrenheit): ")
temp2 = float(input("Please input the temperature: "))

if temp == "1":
    # 攝氏轉華氏
    temp3 = round(temp2 * 9/5 + 32, 2)
    print("Celsius", temp2, "degree = Fahrenheit", temp3, "degree")
elif temp == "2":
    # 華氏轉攝氏
    temp3 = round((temp2 - 32) * 5/9, 2)
    print("Fahrenheit", temp2, "degree = Celsius", temp3, "degree")
else:
    print("Invalid selection! Please enter 1 or 2.")
INFO