013
0.相同缩进1.不能 print没有缩进
2.可以
3.可以
4.不能,缩进不对
----------------------dds
0.
number = int(input("请输入一个整数:"))
if number%2 == 0:
print(number,"是一个偶数。")
else:
print(number,"是一个奇数。")
1.
p = int(input("please input the profit of this year:"))
if p <= 10:
b = p * 0.1
elif 10 < p <= 20:
b = 10 * 0.1 + (p - 10)*0.075
elif 20 < p <= 40:
b = 10 * 0.1 + 10*0.075 + (p-20)*0.05
elif 40 < p <= 60:
b = 10 * 0.1 + 10*0.075 + 20*0.05 + (p-40)*0.03
elif 60 < p <= 100:
b = 10 * 0.1 + 10*0.075 + 20*0.05 + 20*0.03 +(p-60)*0.015
elif 100 < p:
b = 10 * 0.1 + 10*0.075 + 20*0.05 + 20*0.03 + 40*0.015 + (p-100)*0.01
print("hi")
else:
print("input is not correct!")
print("the bonus is:",b)
*********************
改错
dds-0
number类型应该是float
def bonus(amount):
interest = {
1000000: 0.01,
600000: 0.015,
400000: 0.03,
200000: 0.05,
100000: 0.075,
0: 0.1
}
arr = []
for m in interest.keys():
if amount >= m and m:
bal = amount-m
arr.append(bal*interest)
amount = amount-bal
elif not m:
arr.append(amount*interest)
return sum(arr)
print(bonus(1234500))
页:
[1]