三元表達式 在以前,在諸如比較兩個數大小的時候,通常的寫法都是下面的樣子 if x > y:print("the max is x")
else:print("the max is y") 三元表達式的語法為: True if expression else False 現在可以個體三元表達式…
while True:a int(input(攝氏度轉換為華氏溫度請按1\n華氏溫度轉化為攝氏溫度請按2\n))if a 1:celsius float(input(輸入攝氏溫度:))fahreaheit (celsius 1.8) 32 # f c9/532print({:.2f}攝氏溫度轉為華氏溫度為{:.2f}.format(celsius, fahreaheit))elif a …