新聞中心
本篇內(nèi)容主要講解“Python如何計(jì)算個(gè)人應(yīng)發(fā)獎(jiǎng)金”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Python如何計(jì)算個(gè)人應(yīng)發(fā)獎(jiǎng)金”吧!
發(fā)展壯大離不開廣大客戶長期以來的信賴與支持,我們將始終秉承“誠信為本、服務(wù)至上”的服務(wù)理念,堅(jiān)持“二合一”的優(yōu)良服務(wù)模式,真誠服務(wù)每家企業(yè),認(rèn)真做好每個(gè)細(xì)節(jié),不斷完善自我,成就企業(yè),實(shí)現(xiàn)共贏。行業(yè)涉及iso認(rèn)證等,在成都網(wǎng)站建設(shè)、全網(wǎng)整合營銷推廣、WAP手機(jī)網(wǎng)站、VI設(shè)計(jì)、軟件開發(fā)等項(xiàng)目上具有豐富的設(shè)計(jì)經(jīng)驗(yàn)。
需求
企業(yè)發(fā)放的獎(jiǎng)金根據(jù)利潤提成。利潤(I)低于或等于10萬元時(shí),獎(jiǎng)金可提10%;利潤高于10萬元,低于20萬元時(shí),低于10萬元的部分按10%提成,高于10萬元的部分,可提成7.5%;20萬到40萬之間時(shí),高于20萬元的部分,可提成5%;40萬到60萬之間時(shí)高于40萬元的部分,可提成3%;60萬到100萬之間時(shí),高于60萬元的部分,可提成1.5%,高于100萬元時(shí),超過100萬元的部分按1%提成,從鍵盤輸入當(dāng)月利潤I,求應(yīng)發(fā)放獎(jiǎng)金總數(shù)?
思路
分區(qū)間計(jì)算即可。
實(shí)現(xiàn)腳本:
1. JAVA代碼
public class 根據(jù)提成發(fā)放獎(jiǎng)金 { public static void main(String[] args) { System.out.print("請輸入利潤金額:"); Scanner in = new Scanner(System.in); double bonus = 0; //獎(jiǎng)金 double profit = in.nextDouble(); //利潤 in.close(); if(profit<=0) { System.out.println("輸入錯(cuò)誤"); } else if(profit > 0 && profit <= 10) { //小于10萬 bonus = profit * 0.1; } else if(profit > 10 && profit <20) { //10-20萬 bonus = (profit-10) * 0.075 + 1; } else if(profit >=20 && profit <40) { //20-40萬 bonus = (profit-20)*0.05 + 1.75; } else if(profit >=40 && profit < 60) { //40-60萬 bonus = (profit-40)*0.03 + 2.75; } else if(profit >=60 && profit < 100) { //60-100萬 bonus = (profit-60)*0.015 + 3.35; } else { bonus = (profit-100)*0.001 + 3.95; //大于100萬 } System.out.println("獎(jiǎng)金為:"+ (bonus*10000) +"元"); }}
2. python代碼
#!/usr/bin/python#利潤(I)低于或等于10萬元時(shí),獎(jiǎng)金可提10%;利潤高于10萬元,低于20萬元時(shí),低于10萬元的部分按10%提成,#高于10萬元的部分,可提成7.5%;20萬到40萬之間時(shí),高于20萬元的部分,可提成5%;#40萬到60萬之間時(shí)高于40萬元的部分,可提成3%;60萬到100萬之間時(shí),高于60萬元的部分,可提成1.5%,#高于100萬元時(shí),超過100萬元的部分按1%提成,從鍵盤輸入當(dāng)月利潤I,求應(yīng)發(fā)放獎(jiǎng)金總數(shù)?profit=int(input('請輸入利潤金額:\n'))bonus=0thresholds=[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=0breakelse:bonus+=thresholds[i]*rates[i]profit-=thresholds[i]bonus+=profit*rates[-1]print('利潤提成金額:%f' %bonus)
按F5輸出結(jié)果:
如何讓sublime支持帶input()的python程序
1. python文件的界面里點(diǎn)擊上方菜單欄的tools->sublimeREPL->python->python run current file,這時(shí)候就像IDLE一樣,會(huì)彈出一個(gè)新的窗口,而且是可交互的,可以輸入。(這個(gè)操作相當(dāng)于點(diǎn)了下“run”,執(zhí)行代碼,不過每次都要這樣,太麻煩,可以按下面的方法,設(shè)置快捷鍵)
2. 設(shè)置快捷鍵,打開preferences->Key Binding-User,寫入以下內(nèi)容
[ { "keys": ["f5"], "caption": "SublimeREPL:Python", "command": "run_existing_window_command", "args":{"id": "repl_python_run", "file": "config/Python/Main.sublime-menu" } }]
到此,相信大家對“Python如何計(jì)算個(gè)人應(yīng)發(fā)獎(jiǎng)金”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
網(wǎng)站標(biāo)題:Python如何計(jì)算個(gè)人應(yīng)發(fā)獎(jiǎng)金
瀏覽路徑:http://fisionsoft.com.cn/article/pijhis.html