码迷,mamicode.com
首页 > 其他好文 > 详细

day13

时间:2017-03-27 14:47:39      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:bash   and   nbsp   blog   system   name   信息   哈哈   else   

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

标签:bash   and   nbsp   blog   system   name   信息   哈哈   else   

原文地址:http://www.cnblogs.com/oyoui/p/6626343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!