程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python order and branching

編輯:Python

Stepped fare

Summer is coming , The electricity consumption of each household has increased a lot , The corresponding electricity bill also paid more . Xiaoyu's family received a notice of electricity charge today . According to the price of electricity in Fujian [2006]27 Regulation No , The monthly electricity consumption is 150 Kilowatt hours and below per kilowatt hour 0.4463 Yuan Executive , The monthly electricity consumption is 151~400 The part of kWh is per kWh 0.4663 Yuan Executive , The monthly electricity consumption is 401 Kilowatt hours and above per kilowatt hour 0.5663 Yuan Executive , Figure out how much electricity should be paid .

ElectricityConsumption=int(input())
ElectricStep=[150,400]
Price=[0.4463,0.4663,0.5663]
if(ElectricityConsumption<=150):
ElectricityBill=ElectricityConsumption*Price[0]
elif(151<=ElectricityConsumption<=400):
ElectricityBill=66.945+(ElectricityConsumption-ElectricStep[0])*Price[1]
else:
ElectricityBill=183.52+(ElectricityConsumption-ElectricStep[1])*Price[2]
print("%.1f"%ElectricityBill)

Self writing code , The problem stems from the valley of Los Angeles


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved