# Author:Hiuhung Wan #輸入一個攝氏溫度值,轉換成華氏溫度值 notfalse = not False while notfalse: degree_centigrade = input("Please Input the Degree Centigrade:") if degree_centigrade.isdigit(): degree_centigrade = int(degree_centigrade) fahrenheit = '%.2f'%(1.8*degree_centigrade + 32) #保留兩位小數 print("Your input is",degree_centigrade ,"degrees Celsius,\nConverted to Fahrenheit is",fahrenheit,".","\nPress Q or q to exit.") elif degree_centigrade == "q" or degree_centigrade == "Q": notfalse = False else: print("Please enter a number!")
目前輸入小數與負數,會有BUG