'''
练习一:
1.输入年,月,日,输出这一天是这一年的第几天
2.判断是否为闰年
'''
year=int(input("请输入年份:"))
month=int(input("请输入月份:"))
day=int(input("请输入日期:"))
sum=0
months=[31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(month-1):
sum+=months[i]
sum+=day
leap=0 #判断闰年,如果是闰年则加上 一天 不是则不加
if (year%400==0) or (year%4==0 and year%100!=0):
leap=1
if leap==1 and month>2:
sum+=1
print("It is the {} day".format(sum))
'''
请输入年份:2021
请输入月份:11
请输入日期:4
It is the 308 day
'''
'''
练习二
2.企业发放的奖金根据利润提成。
(1)利润低于或等于10万元时,奖金可提10%;
(2)利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的
部分,可提成7.5%;
(3)20万到40万之间时,高于20万元的部分,可提成5%;
(4) 40万到60万之间时高于40万元的部分,可提成3%;
(5) 60万到100万之间时,高于60万元的部分,可提成1.5%, .
(6)高于100万元时,超过100万元的部分按1%提成,
从键盘输入当月利润,求应发放奖金总数
'''
sum = 0
profit = float(input('输入利润,单位万元:'))
if profit<=10:
sum=profit*0.1
elif 10<profit<=20:
sum = 10 * 0.1+(profit-10)*0.075
elif 20<profit<=40:
sum=10*0.1+10*0.075+(profit-20)*0.05
elif 40<profit<=60:
sum=10*0.1+10*0.075+20*0.05+(profit-40)*0.03
elif 60<profit<=100:
sum = 10 * 0.1 + 10 * 0.075 + 20 * 0.05+20*0.03+(profit-60)*0.015
elif profit>100:
sum = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40* 0.015+(profit-100)*0.015
print('奖金是%.2f万'%sum)
'''
输入利润,单位万元:150
奖金是4.70万
'''
python练习题
最新推荐文章于 2024-07-12 16:16:27 发布