# 作业(必做题):
#1. 使用while循环输出1 2 3 4 5 6 8 9 10
# count=0
# while count<10:
# count += 1
# if count ==7:
# continue
# print(count)
#2. 求1-100的所有数的和
# count=0
# x=0
# while count<100:
# x=x+count
# count+=1
# print(x)
#3. 输出 1-100 内的所有奇数
# count=0
# while count<100:
# count += 1
# if count%2==0:
# continue
# print(count)
#4. 输出 1-100 内的所有偶数
# count=0
# while count<100:
# count += 1
# if count%2!=0:
# continue
# print(count)
#5. 求1-2+3-4+5 ... 99的所有数的和
# count=0
# x=0
# while count<99:
# count+=1
# if count % 2 == 1:
# x=x+count
# else:
# x=x-count
# print(x)
#6. 用户登陆(三次机会重试)
# user_info=["egon",'123']
# count=0
# while count<3:
# name=input("请输入用户名:")
# password=input("请输入密码:")
# if name==user_info[0]:
# if password == user_info[1]:
# print("登陆成功")
# else:
# print("密码错误")
# count+=1
# else:
# print("请输入正确用户名")
# count+=1
#7:猜年龄游戏
# 要求:
# 允许用户最多尝试3次,3次都没猜对的话,就直接退出,如果猜对了,打印恭喜信息并退出
# age=18
# count=0
# while count<3:
# guess=input("请输入年龄:")
# guess=int(guess)
# if guess==18:
# print("恭喜猜对了")
# break
# else:
# print("猜错了")
# count+=1
# #8:猜年龄游戏升级版(选做题)
# 要求:
# 允许用户最多尝试3次
# 每尝试3次后,如果还没猜对,就问用户是否还想继续玩,如果回答Y或y, 就继续让其猜3次,以此往复,如果回答N或n,就退出程序
# 如何猜对了,就直接退出
age=18
count=0
while count<3:
guess=input("请输入年龄:")
if guess=='18':
print("恭喜猜对了")
break
else:
print("猜错了")
count += 1
if count==3:
tip=input("是否还要玩,请输入y或n:")
if tip=="y":
count=0
else:
print("游戏结束")