The problem with Python exercises is as follows:
Summary: The bonus paid by the enterprise is based on the profit commission. Profit (I) less than or equal to $100,000, the bonus can be raised by 10%, the profit is higher than $100,000, less than $200,000, the portion of less than 100,000 yuan by 10% commission, higher than the portion of 100,000 yuan, a commission of 7.5%, 200,000 to 400,000, higher than 200,000 yuan, can commission 5% , between 400,000 and 600,000 is higher than the portion of 400,000 yuan, can commission 3%, 600,000 to 1 million, above the portion of 600,000 yuan, can be a commission of 1.5%, higher than 1 million yuan, the portion of more than 1 million yuan by 1% Commission.
Question: Enter the current month profit I from the keyboard, the total bonus should be issued?
#my stupid way.Profit = Int (input ('profit=')) a= Profit * 0.1b= (profit-100000) * 0.075C= (profit-200000) * 0.05D= (profit-400000) * 0.03e= (profit-600000) * 0.015F= (profit-1000000) * 0.01ifProfit <= 100000: Print(a)if100000 < profit <= 200000: Print(A +b)if200000 < profit <= 400000: Print(A + B +c)if400000 < profit <= 600000: Print(A + B + C +d)if600000 < profit <= 1000000: Print(A + B + C + D +e)if1000000 <Profit:Print(A + B + C + D + E + f)
# The answer algorithm, is also understood, to practice mastering a = [1000000, 600000, 400000, 200000, 100000= [0.01, 0.015, 0.03, 0.05 , 0.075, 0.1 = Int (input ('>>>'= 0 for in range (6 ): if profit > a[i]: + = (profit-a[i]) * b[i]Print (Bonus)
Python Programming exercises and Answers example two: exercises on the axis and long integer data types.