测试题——程序

 # 6.计算1 + 2 + 3... + 98 + 99 + 100 用while 语句进行编写 (编程题)
# count = 1 用于循环
# counts =0 用于记录总和值
# while count<=100: 循环条件
# counts=count+counts 循环语句
# print(counts)
# count +=1
# count = 0 用处与while语句中counts一样
# for i in range(1, 101): 循环语句加循环条件
# count = count + i赋值求和
# print(count)
# 8写一个三次认证(编程)实现用户输入用户名和密码,当用户名为 kwx 密码为123时, 显示登陆成功, 否则登陆失败, 失败时允许重复输入三次

# _username2 = 'kwx'
# _password = '123' 赋值以便于判断
# count = 0 循环
# while count < 3:
# username = input("名字>>") 提示输入
# password = input("密码>>")
# if username == _username2 and password == _password:判断
# print("登陆成功")
# break 停止while循环
# else:
# print("登陆失败")
# count += 1
# 9, 1,根据字典的 "price" 值对字典列表进行排序:
# 2,根据字典的 车的名字长度对字典列表进行排序:
posted @ 2020-10-03 20:07  ]龙梦[  阅读(108)  评论(0编辑  收藏  举报