python day02 作业答案

1.

(1).false   (2).false

2.

(1).8  (2).4

3.

(1).6  (2).3  (3).false (4).3   (5).true   (6).true  (7).0  (8).3  (9).0 (10).2

4.

(1).while True:

  循环体

else:

  跳出循环执行这里

5.

count=1
while 1:
number=input("猜猜我的数字:")
if int(number)==66:
print("回答正确")
break
elif int(number)< 66:
print("猜小了")
else :
print("猜大了")

6.

count=1
while 1:
number=input("猜猜我的数字:")
if int(number)==66:
print("回答正确")
break
elif count ==2:
print("太笨了")
count=count+1

7.

count=1
while count<=10:
print(count)
count+=1

8.

count=1
sum=1
while count<=99:
count += 1
sum=sum+count
print(sum)

9.

count=1
while count<=100:
if count %2!=0:
print(count)
count += 1

10.

count=1
while count<=100:
if count %2==0:
print(count)
count += 1

11.

sum=1
count=1
while count<99:
count=count+1
if count %2 ==0:
sum=sum-count
else :
sum=sum+count

12.

count=1
while count<=3:
username = input('请输入用户名:')
password = input("请输入密码:")
if username=='apple' and password =='':
print('登陆成功')
break
else :
print("登陆失败")
print("还剩"+str(3-count)+"次")
count=count+1

13.

14.

a='最'
b='第一'
c='稀缺'
d='*'
ad=input("输入广告:")
if (a or b or c or d) in ad:
print("不合法")
else:
print('合法')
上一篇:python day04 作业答案


下一篇:笔试 - 高德软件有限公司python问题 和 答案