1 ''' 2 1、使用while循环输入 1 2 3 4 5 6 8 9 10 3 4 2、求1-100的所有数的和 5 6 3、输出 1-100 内的所有奇数 7 8 4、输出 1-100 内的所有偶数 9 10 5、求1-2+3-4+5 ... 99的所有数的和 11 12 6、用户登陆(三次机会重试) 13 ''' 14 #1、使用while循环输入 1 2 3 4 5 6 8 9 10 15 # count = 1 16 # while count < 11: 17 # if count == 7: 18 # count += 1 19 # print(count) 20 # count += 1 21 22 #3、输出 1-100 内的所有奇数 23 # count = 1 24 # while count < 101: 25 # print(count) 26 # count += 2 27 28 #5、求1-2+3-4+5 ... 99的所有数的和 29 # sum = 0 30 # count = 1 31 # while count < 100: 32 # if count % 2 == 0: 33 # sum -= count 34 # else: 35 # sum += count 36 # count += 1 37 # print(sum) 38 ''' 39 li = [{'username':'alex','password':'SB'}, 40 {'username':'wusir','password':'sb'}, 41 {'username':'taibai','password':'男神'}, 42 ] 43 #客户输入了三次机会,都没成功,给它一个选择,让它在试试 44 # Y 再给他三次机会...不输入了,print('臭不要脸.....') 45 ''' 46 li = [{'username':'alex','password':'SB'}, 47 {'username':'wusir','password':'sb'}, 48 {'username':'taibai','password':'男神'}, 49 ] 50 j = 0 51 while j < 3: 52 username = input('姓名:') 53 password = input('密码:') 54 for i in li: 55 if username == i['username'] and password == i['password']: 56 print('登录成功') 57 j = 3 58 break 59 else: 60 print('登录不成功,请重新输入') 61 if j == 2: 62 choice = input('是否在试试?Y') 63 if choice == 'Y': 64 j = -1 65 j += 1
first作业---三次登录
猜你喜欢
转载自www.cnblogs.com/lijie123/p/9022373.html
今日推荐
周排行