不打印7:题1:代码:

方法1:

number = 0
while number < 10:
number = number +1
if number != 7 :
print(number)

 

方法2:

number = 0
while number < 10:
number = number +1
if number == 7 :
continue
else
:print(number)

1–100共计:题2:代码:

number = 0
snm = 0
while number < 100:
number = number + 1
snm = snm + number
print(snm)

 

奇数:题3:代码:

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

 

偶数:题4:代码:

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

 

1-2+3-4..99的结果 题5 :代码

number = 1
snm = 1
while snm < 99 :
snm = snm +1
if (snm % 2 ) ==0:
number = number - snm
else: number = number +snm
print(snm)
print(number)

 

三次机会登录题6:代码:

count = 3
while count > 0 :
mima = input('请输入root的密码')
if mima == '123456':
print('登录成功')
break
else
:
count = count - 1
number = str(count)
print('请再次输入密码,还剩下' + number + '次机会')

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注