2024-11-27 14:25
1127 hw pa1
#Python 中的邏輯運算子(運算符)
#and or not
#and
temp = int(input("請輸入現在溫度:"))
if temp > 0 and temp < 30:
print("溫度是適宜的")
else:
print("溫度是不適宜的")
Conclusion:
And要前後兩者條件為ture才成立
#or
temp = int(input("請輸入現在溫度:"))
if temp <= 0 and temp >= 30:
print("溫度不適宜")
else:
print("溫度適宜")
Conclusion:
Or只要其中一個條件就可以進入了