剛開始學習python3,以下是計算勞務報酬所得的**,各位大神歡迎從** 結構、規範性、效能、更簡潔書寫方式方面給出一些批評意見!
ps:其中有一段**重複,是否有好的方法可以避免重複**?
#!/usr/bin/python3
# -*- coding:utf-8 -*-
# filename:servicefee.py
defservicefee()
:"""
# 勞務報酬:service_fee
# 預扣預繳應納稅所得額:serv_income
# 應納稅額:tax_fee
# 稅後勞務所得:after_tax_fee
"""# 預扣預繳應納稅所得額扣除指數
serv_rate =
# 個人所得稅稅率表:應納稅所得額 含稅: 0, 不含稅:1
tax_rate =
var0 =
int(
input
('請選擇您的勞務報酬是否含稅,含稅輸入"1",不含稅輸入"0":\n'))
service_fee =
float
(input
('請輸入勞務報酬金額:\n'))
if service_fee <= serv_rate[0]
: tax_fee =
0elif service_fee > serv_rate[0]
and service_fee <= serv_rate[1]
[0]:
serv_income = service_fee - serv_rate[1]
[1]if serv_income <= tax_rate[var0][0
][0]
: tax_fee = serv_income * tax_rate[0]
[0][
1]elif serv_income > tax_rate[var0][0
][0]
and serv_income <= tax_rate[var0][1
][0]
: tax_fee = serv_income * tax_rate[var0][1
][1]
- tax_rate[var0][1
][2]
else
: tax_fee = serv_income * tax_rate[var0][2
][0]
- tax_rate[var0][2
][1]
else
: serv_income = service_fee *(1
- serv_rate[2]
)if serv_income <= tax_rate[var0][0
][0]
: tax_fee = serv_income * tax_rate[0]
[0][
1]elif serv_income > tax_rate[var0][0
][0]
and serv_income <= tax_rate[var0][1
][0]
: tax_fee = serv_income * tax_rate[var0][1
][1]
- tax_rate[var0][1
][2]
else
: tax_fee = serv_income * tax_rate[var0][2
][0]
- tax_rate[var0][2
][1]
after_tax_fee = service_fee - tax_fee
print
("勞務報酬:%d\n應納稅額:%d\n稅後勞務所得:%d"
%(service_fee, tax_fee, after_tax_fee)
)if __name__ ==
'__main__'
: servicefee(
)
python3 計算python指令碼的執行時間
首先說一下我遇到的坑,生產上遇到的問題,我排程python指令碼執行並監控這個程序,python指令碼執行時間遠遠大於python指令碼中自己統計的程式執行時間。監控python指令碼執行的時間是36個小時,而python指令碼中統計自己執行的時間是4個小時左右。問題暴漏之後首先想到的是linux出...
python3 切片 python3 切片
取乙個list或tuple的部分元素是非常常見的操作。比如,乙個list如下 l michael sarah tracy bob jack 取前3個元素,應該怎麼做?笨辦法 l 0 l 1 l 2 michael sarah tracy 之所以是笨辦法是因為擴充套件一下,取前n個元素就沒轍了。取前n...
python3安裝 Python3的安裝
1.anaconda安裝 2.安裝包安裝 3.linux下的命令列安裝 centos red hat 1 sudo yum install y sudo yum update3 sudo yum install y python35u python35u libs python35u devel p...