python day07作业答案

1.

sum=0
a=input()
for i in a:
sum=sum+int(i)**3
if sum==int(a):
print('水仙数')

2.

lst=[100,2,6,9,1,10,12,35,1,9,65,8,100,0,1,9,5,6]
count=0
while count<len(lst):
for i in range(0, len(lst) - 1):
if lst[i] > lst[i + 1]:
lst[i ], lst[i+1] = lst[i+1], lst[i ]
count+=1
print(lst)

3.

from random import randint
a=randint(0,20)
lst=set()
count=0
while len(lst)<7:
lst.add(randint(0,20))
print(lst)

4.

a=int(input('输入工资:'))
sum=0
if a <2000:
sum=sum+0
elif a <4000:
sum=sum+(a-2000)*0.03
elif a <6000:
sum=sum+(a-4000)*0.04+2000*0.03
elif a<10000 :
sum=sum+(a-6000)*0.08+2000*0.04+2000*0.03
elif a >10000:
sum=sum+(a-10000)*0.2+2000*0.08+2000*0.04+2000*0.03
print(sum)
print(a-sum)
上一篇:python day08作业答案


下一篇:python day06 作业答案