Latest web development tutorials

Python Exercise Example 2

Python Exercise Example 2

Python 100 Li Python 100 Li

Title: Corporate bonuses based on profit commission. When profits (I) is less than or equal to $ 100,000, bonus of 10% can be mentioned; when profits exceeding 10 million, less than 20 million, some 10 million less than the 10% commission, higher than 100,000 yuan part of cocoa commission of 7.5%; when between 200,000 to 400,000, more than 20 million parts can be 5% commission; when between 400,000 to 600,000 higher than 400,000 yuan section, you can deduct a percentage of 3% ; when between 600 thousand to 1 million, more than 60 million yuan section, you can deduct a percentage of 1.5%, higher than 100 million, more than 1 million yuan part 1% commission from the keyboard input of the month profit I, should seek Total bonuses paid?

Program Analysis: Please use the number of axes boundaries, location. The growing need to define integer bonus note definition.

Source Code:

Examples (Python 2.0+)

#! / usr / bin / python # - * - Coding: UTF- 8 - * - i = int (raw_input ( 'net:')) 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

The above example output is:

净利润:120000
1500.0
10000.0
11500.0

Python 100 Li Python 100 Li