比较三个数中最大的一个
a=float(input("a="))
b=float(input("b="))
c=float(input("c="))
my_max=a>b and a or b
my_max=c>b and c or my_max
print(my_max)
说明:条件成立取 and后的值,条件不成立取or 后面的值。
或
import math
….
print(max(a,b,c))
计算个人所得税
salary=float(input("本月收入:"))
insurance=float(input("五险一金:"))
diff=salary-insurance-3500
if diff<=0:
tax=o
deducation=0
elif diff<=1500:
rate=0.03
deducation=0
elif diff<=4500:
tax=0.1
deducation=105
elif diff<9000:
tax=0.2
deducation=555
elif diff<=35000:
tax=0.25
deducation=1005
elif diff<=55000:
rate=0.3
deducation=2755
elif diff<=85000:
rate=0.35
deducation=5505
else:
rate=0.45
deducation=13505
p=diff*rate-deducation
print("个人应交税为:%.3f"%p)