当我的输出应该是“住宅、商业、城市和教区”时,我得到的是“R、B、C和p”
我也得到0.00为我的总数,我需要的总数,如果它是一个企业,城市,或教区(他们都是不同的)…这不是计算。你知道吗
我从一个.data文件中获取输入,它们是正确的
print("=========================================================")
print(format("Name", '<12s'),format("Type", '<15s'),format("Location", '<10s'),format("KwH", '>6s'),format("Total", '>10s'))
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"):
custLoc = "City"
total = (custKwh * 0.0401) + 6
if (custLoc == "P"):
custLoc = "Parish"
total = (custKwh * 0.04411) + 6.60
print(format(custName, '<12s'),format(custType, '<15s'),format(custLoc, '<10s'),format(custKwh, '>6d'),format(total, '>10.2f'))
输入为:
Smith R P 4500 Taylor R C 6000 Williams B C 10500 Johnson R C 7500 Davis R P 3000 Woods B P 25300 Morgan R C 5800 Landry R C 3900 Young B P 18500 Wilson R P 7000
我会重写如下:
这里的关键错误是,在检查custLoc(复制粘贴错误?)你知道吗
相关问题 更多 >
编程相关推荐