☞☞☞ Click to see more outstanding Python blog ☜☜☜
Python includes exercises 2
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 part, 7.5% cocoa commission; is between 200,000 to 400,000, more than 20 million portion may commission 5%; more than 40 million portion is between 400,000 to 600,000, may be 3% commission ; is between 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?
Program Analysis : Please use axes to cut-off, location. The bonus to be defined in Note grow integer defined.
Source Code :
#!/usr/bin/python
# -*- coding: UTF-8 -*-
i = int(raw_input('净利润:'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
r+=(i-arr[idx])*rat[idx]
print (i-arr[idx])*rat[idx]
i=arr[idx]
print r
Examples of the above output is:
净利润:120000 1500.0 10000.0 11500.0