day 1 作业
一、作业需求:1.编写登陆接口
2.成功登陆后显示欢迎信息
3.输入三次错误,锁定账号
1 username = "keven" 2 password = "abc123" 3 i = 0 4 while i < 3: 5 user_input=input("pls input your username:") 6 pwd_input=input("pls input your password:") 7 if user_input == username and pwd_input == password: 8 print("wellcome {}".format(username)) 9 break 10 else: 11 print("username or password incorrect") 12 i += 1 13 else: 14 print("username locked")
1 username = "keven" 2 password = "abc123" 3 i = 0 4 while i < 3: 5 user_input=input("pls input your username:") 6 pwd_input=input("pls input your password:") 7 if user_input == username and pwd_input == password: 8 print("wellcome {}".format(username)) 9 break 10 else: 11 print("username or password incorrect") 12 i += 1 13 else: 14 print("username locked")
二、作业要求:
1.三级菜单
2.可以依次进入新菜单
1 data={ 2 "a":{"a1":{"a11":["a111,a112"], 3 "a12":["a121","a122"] 4 }, 5 "a2":{"a21":["a211","a212"], 6 "a22":["a221","a222"]}, 7 }, 8 "b":{ 9 "b1":{"b11":["b111,b112"], 10 "b12":["a121","a122"]}, 11 "b2":{"b21":["b211","b212"], 12 "b22":["b221","b222"]}, 13 }, 14 } 15 print("操作说明:按 r 返回,按 q 退出") 16 exit_flag=1 17 while exit_flag==1: 18 for i in data: 19 print(i) 20 u_choice=input("pls input your choice:") 21 if u_choice in data: 22 while exit_flag == 1: 23 for i1 in data[u_choice]: 24 print("\t"+i1) 25 u_choice1=input("pls input your choice:") 26 if u_choice1 in data[u_choice]: 27 while exit_flag == 1: 28 for i2 in data[u_choice][u_choice1]: 29 print("\t\t"+i2) 30 u_choice2=input("pls input your choice:") 31 if u_choice2 in data[u_choice][u_choice1]: 32 while exit_flag == 1: 33 for i3 in data[u_choice][u_choice1][u_choice2]: 34 print ("\t\t\t"+i3) 35 u_choice3=input("pls input your choice") 36 if u_choice3 == "r": 37 break 38 elif u_choice3 == "q": 39 exit_flag == 0 40 else: 41 print("option incorrect,pls try again") 42 elif u_choice2 == "r": 43 break 44 else: 45 print("option incorrect,pls try again") 46 elif u_choice1 == "r": 47 break 48 else: 49 print("option incorrect,pls try again") 50 else: 51 print("option incorrect,pls try again")

浙公网安备 33010602011771号