day10

在猜年龄的基础上编写登录、注册方法,并且把猜年龄游戏分函数处理,如

  1. 登录函数
  2. 注册函数
  3. 猜年龄函数
  4. 选择奖品函数

登录函数

def login():
    """登录功能"""
count = 0
while count < 3
    username_inp = input('请输入用户名')
    pwd_ino = input('请输入密码')
    if username.strip()  == username_inp and pwd.strip () == pwd_inp
        print('登录成功')
    else:
        continue
else:
    print('登录失败')
    break

注册函数

def register():
    """注册功能"""
count = 0
while count < 3
    username_inp = input('请输入用户名')
    pwd_ino = input('请输入密码')
    re_pwd_inp = input('请再次输入密码')
    if not pwd_inp ==re_ped_inp
        print('密码错误')
    else:
        print('密码正确')
        count += 1
        break

猜年龄函数

count = 0
while count < 3
    age = 18
    age_inp_int = input('请输入年龄')
    if not age_inp_int < age :
        print9('猜小了')
        if not age_inp_int > age :
            print('猜大; ')
    else:
        print('正确')
        count += 1
        break

选择奖品函数

prize_dict={'0':"比蒂"
            '1':'psp''2':"手办"'3':"手机"}
prize_choice = input('请选择;prize_dict')
print('恭喜\prize_choice')
count = 0
while count < 2
    print(f'奖品如下:{prize_dict}')
prize_choice = input('请选择')
print{f'prize_dict[prize_choicec}'}
count += 1
break

posted @ 2019-09-19 20:12  夜凛  阅读(64)  评论(0编辑  收藏  举报