幻树师 发表于 2020-9-22 22:50:34

分支循环作业题


看不懂这个错,求解
num = int(input("请输入今年的利润:"))

if num <= 100000:
    reward = num*(0.1)


elif 100000 < num <= 200000:

    reward = 100000*0.1 +(num - 100000)* (0.075)
   
elif 200000 < num <= 400000:
   
    reward = 100000*0.1 + 100000*0.075 +(num - 200000)* (0.05)

elif 400000 < num <= 600000:
    reward = 100000*0.1 + 100000*0.075 + 200000*0.05 +(num - 400000)* (0.03)
elif 600000 < num <= 1000000:
   
    reward =(100000*0.1 + 100000*0.075+ 200000*0.05 + 200000*0.03 +(num - 600000)* (0.015)
else:
   
    reward = 100000*0.1 + 100000*0.075+ 200000*0.05 + 200000*0.03 + 400000*0.015 +(num - 1000000)* (0.01)
   
   
print("应该发放的奖金总数是: ",reward,sep='')

baige 发表于 2020-9-22 23:10:05

else上一行后面少了个)

昨非 发表于 2020-9-22 23:11:32


num = int(input("请输入今年的利润:"))

if num <= 100000:
    reward = num*(0.1)

elif 100000 < num <= 200000:
    reward = 100000*0.1 +(num - 100000)* (0.075)
   
elif 200000 < num <= 400000:
    reward = 100000*0.1 + 100000*0.075 +(num - 200000)* (0.05)

elif 400000 < num <= 600000:
    reward = 100000*0.1 + 100000*0.075 + 200000*0.05 +(num - 400000)* (0.03)

elif 600000 < num <= 1000000:   
    reward =(100000*0.1 + 100000*0.075+ 200000*0.05 + 200000*0.03 +(num - 600000)* (0.015))

else:
    reward = 100000*0.1 + 100000*0.075+ 200000*0.05 + 200000*0.03 + 400000*0.015 +(num - 1000000)* (0.01)
      
print("应该发放的奖金总数是: ",reward,sep='')

昨非 发表于 2020-9-22 23:12:03

baige 发表于 2020-9-22 23:10
else上一行后面少了个)

抱歉没看到已经回复了

幻树师 发表于 2020-9-23 14:15:50

baige 发表于 2020-9-22 23:10
else上一行后面少了个)

谢谢

幻树师 发表于 2020-9-23 14:16:30

昨非 发表于 2020-9-22 23:11


谢谢
页: [1]
查看完整版本: 分支循环作业题