Python, small practice

Topic: Enterprise commission bonuses based on profits. 
When profit (I) is less than or equal to 10 million, 10% of the prize can be mentioned;
when profit than 10 million, less than 20 million, 10 million commission portion is less than 10%,
higher than 100,000 yuan portion, may be 7.5% commission; is between 200,000 to 400,000, more than 20 million portion, may be 5% commission;
when more than 40 million portion between 400,000 to 600,000, may be 3% commission ;
is between from 600,000 to 1,000,000, more than 60 million portion may commission 1.5%
above 100 million, more than one million yuan portion 1% commission,
from the keyboard month profit I, should seek The total number of paid bonuses?
The first:
I = float(input("请输入你的利润(万元):"))
bonu = 0
if I <= 10:
    bonu = I * 10000 * 0.1
elif I > 10 and I <= 20:
    bonu = 100000 * 0.1 + (I - 10) * 100000 * 0.075
elif I > 20 and I <= 40:
    bonu = 100000 * 0.1 + 100000 * 0.075 + (I - 20) * 100000 * 0.05
elif I > 40 and I <= 60:
    bonu = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (I - 40) * 100000 * 0.03
elif I > 60 andThe I <= 100 : 
    Bonu = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (the I - 60) * 100000 * 0.015
 elif the I> 100 : 
    Bonu = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 0.03 + 400000 200000 * + * + 0.015 (the I - 100) 10000 * 0.01 * Print ( " your prize is: " , Bonu)

The second:

i = int(input('净利润:'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
bonu = 0
for idx in range(0, 6):
    if i > arr[idx]:
        bonu += (i - arr[idx]) * rat[idx]
        # print((i - arr[idx]) * rat[idx])
        i = arr[idx]

print(bonu)

 

Guess you like

Origin www.cnblogs.com/hxf-zb/p/11203789.html