您好,登錄后才能下訂單哦!
2 # 題目:企業(yè)發(fā)放的獎(jiǎng)金根據(jù)利潤(rùn)提成。利潤(rùn)(I)低于或等于10萬(wàn)元時(shí),獎(jiǎng)金可提10%;利潤(rùn)高于10萬(wàn)元,低于20萬(wàn)元時(shí),低于10萬(wàn)元的部分按 10%提成,高于10萬(wàn)元的部分,可可提成7.5%;20萬(wàn)到40萬(wàn)之間時(shí),高于20萬(wàn)元的部分,可提成5%;40萬(wàn)到60萬(wàn)之間時(shí)高于40萬(wàn)元的部分, 可提成3%;60萬(wàn)到100萬(wàn)之間時(shí),高于60萬(wàn)元的部分,可提成1.5%,高于100萬(wàn)元時(shí),超過(guò)100萬(wàn)元的部分按1%提成,從鍵盤輸入當(dāng)月利潤(rùn)I, 求應(yīng)發(fā)放獎(jiǎng)金總數(shù)?
2 3 profit = float(input('請(qǐng)輸入當(dāng)月利潤(rùn)(單位為萬(wàn)元):')) 4 5 if profit <= 10: 6 bonus = profit*0.1 7 8 elif profit > 10 and profit <= 20: 9 bonus = 10*0.1 + (profit-10)*0.075 10 11 elif profit > 20 and profit <= 40: 12 bonus = 10*0.1 + 10*0.075 + (profit-20)*0.05 13 14 elif profit > 40 and profit <= 60: 15 bonus = 10*0.1 + 10*0.075 + 20*0.05 + (profit-40)*0.03 16 17 elif profit > 60 and profit <= 100: 18 bonus = 10*0.1 + 10*0.075 + 20*0.05 + 20*0.03 + (profit-60)*0.015 19 20 elif profit > 100: 21 bonus = 10*0.1 + 10*0.075 + 20*0.05 + 20*0.03 + 40*0.015 +(profit-100)*0.01 22 23 print('應(yīng)發(fā)放的獎(jiǎng)金為:%.5f萬(wàn)元'%bonus)
運(yùn)行結(jié)果
[root@HK code_100]# python code_2.py 請(qǐng)輸入當(dāng)月利潤(rùn)(單位為萬(wàn)元):78 應(yīng)發(fā)放的獎(jiǎng)金為:3.62000萬(wàn)元 [root@HK code_100]#
腳本解釋
此腳本用判斷語(yǔ)句表示,也可用list寫(xiě),主要是按類判斷,計(jì)算每一個(gè)區(qū)間的利潤(rùn)數(shù) 2 3 profit = float(input('請(qǐng)輸入當(dāng)月利潤(rùn)(單位為萬(wàn)元):')) #接收輸入的利潤(rùn)數(shù),并且轉(zhuǎn)換成浮點(diǎn)型 4 5 if profit <= 10: #利潤(rùn)小于10萬(wàn)的情況 6 bonus = profit*0.1 7 8 elif profit > 10 and profit <= 20: #類推 9 bonus = 10*0.1 + (profit-10)*0.075 10 11 elif profit > 20 and profit <= 40: #類推 12 bonus = 10*0.1 + 10*0.075 + (profit-20)*0.05 13 14 elif profit > 40 and profit <= 60: #類推 15 bonus = 10*0.1 + 10*0.075 + 20*0.05 + (profit-40)*0.03 16 17 elif profit > 60 and profit <= 100: #類推 18 bonus = 10*0.1 + 10*0.075 + 20*0.05 + 20*0.03 + (profit-60)*0.015 19 20 elif profit > 100: #類推 21 bonus = 10*0.1 + 10*0.075 + 20*0.05 + 20*0.03 + 40*0.015 +(profit-100)*0.01 22 23 print('應(yīng)發(fā)放的獎(jiǎng)金為:%.5f萬(wàn)元'%bonus) #格式化輸出結(jié)果,精確到小數(shù)點(diǎn)后5位 24
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。