首页 > 代码库 > day13
day13
1.猜年龄,最多输入三次
count = 1 age = 8 while count <= 3: guess_age = int(input("please input your age: ")) if guess_age == age: print("You‘re right") exit() elif count == 3: exit() else: print("try agin..") count = count + 1
2.猜年龄 ,每隔3次,问他一下,还想不想继续玩,y,n
count = 1 age = 18 while True: guess_age = int(input("please input your age: ")) if guess_age == age: print("You‘re right") exit() elif (count % 3) == 0: count += 1 play = input("do you want to paly{y|n}") if play == "y": continue else: exit() else: print("you‘re wrong") count +=1
3.编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定
import os count = 1 name = "tom" passwd = "123456" while count <= 3: guess_name = input("please input your name: ") guess_passwd = input("please input your password: ") if guess_name == name and guess_passwd == passwd: print("welcome..") exit() elif count == 3: os.system("sed -i ‘/tom/s/bin\/bash/sbin\/nologin/‘ /etc/passwd") print("Your account is locked...哈哈") exit() else: print("try agin..") count = count + 1
day13
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。