python3发放奖金_发放梯度奖金示例

发放梯度奖金示例:

vi aa.py

#!/usr/bin/python

-,- coding:UTF-8 --

arr = [100000,60000,40000,20000,10000,0]

rat = [0.01,0.015,0.03,0.05,0.075,0.1]

while True:

i = input('净利润(q退出): ')

if i == 'q':

exit(0)

if not i.isdigit():

continue

reward = []

print("奖金为: ",end=' ') #不换行

I=int(i)

for idx in range(0,6):

if I > arr[idx]:

reward.append((I - arr(idx)) * rat[idx])

I = arr[idx]

reward.reverse() # 逆序奖金列表

if (len(reward)) == 1: # 如果只有1个,直接输出

print(reward[0])

else:

print(" + ".join([str(num) for num in reward]), "=",sum(reward))

:wq

python aa.py

你可能感兴趣的:(python3发放奖金)