### 電價計算 ``` #電價計算 e = eval(input()) i = 1 total = 0 if e>0: if e>500: c = e-500 total = 200*2 + 200*3 + c*5 elif e>300: c = e-300 total = 200*2 + c*3 elif e>100: c = e-100 total = c*2 else: total=0 print(total,"元",sep="") else: print("ERROR") ``` ### 408 ``` #408. totalE=0 totalO=0 for i in range(1,11): a = eval(input()) if a%2==0: totalE += 1 elif a%2!=0: totalO += 1 print(f"Even numbers:{totalE:>2}") print(f"Odd numbers:{totalO:>2}") ``` ### 高速公路超速罰款 ``` #高速公路超速罰款 l = eval(input()) e = eval(input()) e = e-l if e>0 and l>0: if e>60: total = 6000 elif e>40: total = 5000 elif e>20: total = 3500 else: total=3000 print("超速",e,",罰",total,"元",sep="") elif l<0: print("ERROR") elif e<0: print("不處罰") ``` ### 209. 距離判斷 ``` #209. 距離判斷 import math x2 = eval(input()) y2 = eval(input()) a = math.sqrt((5-x2)**2+(6-y2)**2) if a>15: print("Outside") else: print("Inside") ``` ### 406 ``` #406. height=0 weight=0 while height!=-9999 or weight!=-9999: height = eval(input()) if height==-9999 or weight==-9999: break weight = eval(input()) if height==-9999 or weight==-9999: break x = ((height / 100) * (height / 100)) y = ((weight / x)) BMI=(round(y,2)) print(f"BMI: {BMI:0.2f}") if BMI<18.5: print("State: under weight") elif BMI<25: print("State: normal") elif BMI<30: print("State: over weight") elif BMI>=30: print("State: fat") ``` ### 飲料自動販賣機 ``` Type=str(input()) NC=eval(input()) if Type=="1": print("訂購紅茶",NC,"杯共",30 * NC,"元") elif Type=="2": print("訂購果汁",NC,"杯共",50 * NC,"元") elif Type=="3": print("訂購咖啡",NC,"杯共",80 * NC,"元") elif Type=="4": print("訂購綠茶",NC,"杯共",20 * NC,"元") else: print("輸入錯誤") ```