python----测试03.27

作业1    猜年龄,可以让用户最多才三次

my_age = 28
count = 0          #count 计数
while count < 3:
    user_guess = int(input("input your guess num:"))
    if user_guess == my_age:
        print("Congratulations,you got it!")
        break
    elif user_guess > my_age:
        print("Bigger!")
    else:
        print("Smaller!")
    count += 1
else:
    print("Sorry!No chance!")

作业2 猜年龄 ,每隔3次,问他一下,还想不想继续玩,y or n
my_age = 28
count = 0          #count 计数
while True:
    user_guess = int(input("input your guess num:"))            #num 号码
    count += 1
    if user_guess > my_age:
        print("Bigger!")
    elif user_guess < my_age:
        print("Smaller!")
    else:
        print("Congratulations,you got it!")
        break
    while count % 3 == 0:
        user_choice = input("Would you like to continue,(y ro n):")      #choice 选择
        if user_choice =="y":
            break
        elif user_choice =="n":
            exit()
        else:
            print("please input y or n")

作业3,编写登陆接口,输入用户名密码,认证成功后显示欢迎信息,输错三次后锁定
posted @ 2017-03-27 17:32  ForeverPine  阅读(191)  评论(0)    收藏  举报
TOP