我需要的總數來計算......越來越0.00if語句在一個循環中,python3
還需要住宅,商業,城市和教區打印
這是我更新的代碼,
使用「」if (custType == "R"):
custType = Residential
你需要把信放在引號的原因
print("=========================================================")
print(format("Name", '<12s'),format("Type", '<15s'),format("Location",'<10s'),format("KwH", '<8s'),format("Total", '>8s'))
print("=========================================================")
total = 0
for i in range(10):
custName = input()
custType = input()
custLoc = input()
custKwh = eval(input())
if (custType == "R"):
custType = "Residential"
if (custType == "B"):
custType = "Business"
total = (custKwh * 0.05710) + 10
if (custLoc == "C"):
custType = "City"
total = (custKwh * 0.0401) + 6
if (custLoc == "P"):
custType = "Parish"
total = (custKwh * 0.04411) + 6.60
print(format(custName, '<12s'),format(custType, '<15s'),format(custLoc, '<10s'),format(custKwh, '<8d'),format(total, '<7.2f'))
即時通訊從數據文件輸入是R,B,C或P – user2865217