标签:习题 sha 输入 lse class NPU key 重试 and
# 1、 使用while循环输入1 2 3 4 5 6 8 9 10
count = 1
while count <= 10:
if count != 7:
print(count)
count += 1
# 2、求1-100的和
count = 1
sum = 0
while count <=100:
sum += count
count += 1
print(sum)
# 3、输出1-100的所有奇数
count = 1
while count <= 100:
if count % 2:
print(count)
count += 1
# 4、输出1-100的所有偶数
count = 1
while count <= 100:
if count % 2 == 0:
print(count)
count += 1
# 5、求1-2+3-4+5 ... 99的所有数的和
count = 1
sum = 0
while count < 100:
if count % 2 ==1:
sum += count
else:sum -= count
count += 1
print(sum)
# 6、用户登录(失败则重试三次)
users = {‘wangjing‘:‘jingjing‘,‘wangxiao‘:‘xiaoxiao‘}
count = 1
while count <=3:
username = input(‘请输入您的用户名:‘)
pasword = input(‘请输入您的密码:‘)
if username in users.keys() and pasword == users[username]:
print(‘登录成功‘)
elif count != 3:
print(‘登录失败,您还可以登录‘ + str(3-count) + ‘次‘)
count += 1
else:print(‘登录失败,您不能再登录了‘)
标签:习题 sha 输入 lse class NPU key 重试 and
原文地址:https://www.cnblogs.com/txbbkk/p/12528398.html