# 1. 使用while循环输出1 2 3 4 5 6     8 9 10

count = 0
while count < 10:
    count += 1
    print(count)
    if count == 6:
        count+=1
        continue
        
#2. 求1-100的所有数的和

s = 0
count = 1
while count < 101:
    s += count
    count += 1
print(s)

#3. 输出 1-100 内的所有奇数

count = 1
while count < 101:
    if count % 2 == 1:
        print(count)
    count += 1
    
#4. 输出 1-100 内的所有偶数

count = 1
while count < 101:
    if count % 2 == 0:
        print(count)
    count += 1
    
#5. 求1-2+3-4+5 ... 99的所有数的和

s = 0
count = 1
while count < 101:
    if count % 2 == 1:
        s += count
    if count % 2 == 0:
        s -= count
    count += 1
print(s)

#6. 用户登陆(三次机会重试)

username = 'yu'
userpwd = '123'
count = 0
flag = True
while flag:
    if count == 3:
        print("输入次数过多,已退出")
        break
    inp_name = input("请输入账号:")
    inp_pwd = input("请输入密码:")

    if inp_name == username and inp_pwd == userpwd:
        print("登陆成功")
    else:
        print("登录失败请重新输入")
        count += 1
        
#7:猜年龄游戏
# 要求:
# 允许用户最多尝试3次,3次都没猜对的话,就直接退出,如果猜对了,打印恭喜信息并退出
    
age = 18
count = 0
flag = True
while count < 3:
    inp_age = int(input("请输入您猜的年龄:"))

    if inp_age == age:
        print("恭喜您猜对了")
        break
    else:
        print("您猜错了请继续猜")
        count += 1

#8:猜年龄游戏升级版(选做题)
# 要求:
#     允许用户最多尝试3次
#     每尝试3次后,如果还没猜对,就问用户是否还想继续玩,如果回答Y或y, 就继续让其猜3次,以此往复,如果回答N或n,就退出程序
#     如何猜对了,就直接退出

age = 18
count = 0
flag = True
while flag:
    while count < 3 and flag == True:
        inp_age = int(input("请输入您猜的年龄:"))

        if inp_age == age:
            print("恭喜您猜对了")
            flag = False
            break
        else:
            print("您猜错了请继续猜")
            count += 1
    else:
        res = input("是否还想继续玩:是输入Y/y否输入N/y")
        if res == 'Y' or res == 'y':
            count = 0
        elif res == 'N' or res == 'n':
            break
        else:
            break