Python_每日習題_0002_個稅計算
阿新 • • 發佈:2019-04-07
color input 總數 60萬 class pro bsp 每次 100萬
# 題目 企業發放的獎金根據利潤提成。利潤(I)低於或等於10萬元時, # 獎金可提10%;利潤高於10萬元,低於20萬元時,低於10萬元的部分按10%提成, # 高於10萬元的部分,可提成7.5%;20萬到40萬之間時,高於20萬元的部分,可提成5%; # 40萬到60萬之間時高於40萬元的部分,可提成3%;60萬到100萬之間時,高於60萬元的部分, # 可提成1.5%,高於100萬元時,超過100萬元的部分按1%提成,從鍵盤輸入當月利潤I,求應發放獎金總數? # 程序分析 分區間計算即可。 profit = int(input(‘Show me the miney‘)) bonus = 0 thresholds= [100000,100000,200000,200000,400000] #每次改變提成金額區間的差值 rates = [0.1,0.075,0.05,0.03,0.015,0.01] for i in range(len(thresholds)): if profit <= thresholds[i]: bonus += profit*rates[i] profit=0 break else: bonus += thresholds[i]*rates[i] profit -= thresholds[i] bonus += profit*rates[-1] #最後算上超過1000000的提成 print(bonus)
Python_每日習題_0002_個稅計算