python小练习

‘’’
age=input(“请输入你的年龄:”)
print("–开始判断–")
if age>=str(18):
print(“已成年”)
else:
print(“未成年”)
‘’’
‘’’
money=input(“上车请刷卡:”)
if money>=str(2):
print(“您已支付2元,请选座”)
set=input(“剩余座位:”)
if set>str(0):
print(“请坐”)
else:
print(“座位已满,请扶好”)
else:
print(“余额不足,请充值”)
‘’’
‘’’
1:女生节做活动;从键盘输入年纪,如果年纪小于18岁,则输出进动物园不用买票,
如果年纪大于18岁,判断如果是女生门票为10元,男生门票为30元(if嵌套)
‘’’
‘’’
age=input(“请输入年龄:”)
if int(age)>=18:
piao=input(“请买票(男生门票或女生门票):”)
if piao==str(“男生门票”):
print(“门票为30元”)
else:
print(“门票为10元”)
else:
print(“进动物园不用买票”)
‘’’
‘’’
2:动物园买票规则:如果年纪在1~18岁之间门票免费,
在19~35岁之间门票为30元,在35岁以上门票为15元(if–elif—else)
‘’’
‘’’
age=input(“请输入年龄:”)
if int(age)>1 and int(age)<=18:
print(“门票免费”)
elif int(age)>19 and int(age)<=35:
print(“门票为30元”)
elif int(age)>35:
print(“门票为15元”)
else:
print(“年龄输入不符合要求”)
‘’’
‘’’
双十一优惠大酬宾:凡是前99名下单的顾客免费,否则不提供免费政策;
前100到400名下单的顾客,
如果是100到200名下单的顾客,输出商品2折出售,
201到301名下单的顾客,输出所有商品半价出售,
否则所有商品8折出售;
400名以后的顾客提示不提供打折
‘’’
‘’’
ranking=input(“请输入下单排名:”)
if int(ranking)<=99:
print(“免费”)
else:
print(“不提供免费政策”)
if int(ranking) >= 100 and int(ranking) <= 400:
if int(ranking) >= 100 and int(ranking) <= 200:
print(“商品2折出售”)
if int(ranking) >= 201 and int(ranking) <= 301:
print(“所有商品半价出售”)
if int(ranking) >= 301 and int(ranking) <= 400:
print(“所有商品8折出售”)
else:
print(“400名以后的顾客不提供打折”)
‘’’
‘’’
python小练习_第1张图片

print(“请玩家输入:剪刀(0),石头(1).布(2)”)
p1 = int(input(“玩家1:”))
p2 = int(input(“玩家2:”))
if (p1 == 0 and p2 == 1) or (p1 == 1 and p2 == 2) or (p1 == 2 and p2 == 0):
print(“玩家一胜出”)
elif (p1 == 1 and p2 == 0) or (p1 == 2 and p2 == 1) or (p1 == 0 and p2 == 2):
print(“玩家二胜出”)
elif p1 == p2 and (p1 >=0 and p1 <=2) and (p2>=0 and p2<=2):
print(“平局”)
else:
print(“录入数据有误”)
‘’’
print(“猜拳游戏开始!”)
guess1=input(“请玩家一输入目标:”)
if int(guess1)==0:
print(“剪刀”)
elif int(guess1)==1:
print(“石头”)
elif int(guess1)==2:
print(“布”)
else:
print(“输入有误”)
exit(0)
guess2=input(“请玩家二输入目标:”)
if int(guess2)==0:
print(“剪刀”)
elif int(guess2)==1:
print(“石头”)
elif int(guess2)2:
print(“布”)
else:
print(“输入有误”)
if guess1
guess2:
print(“平局”)
if int(guess1)==0 and int(guess2)==1:
print(“玩家二获胜”)
if int(guess1)==0 and int(guess2)==3:
print(“玩家一获胜”)
if int(guess1)==1 and int(guess2)==0:
print(“玩家一获胜”)
if int(guess1)==1 and int(guess2)==2:
print(“玩家二获胜”)
if int(guess1)==2 and int(guess2)==0:
print(“玩家二获胜”)
if int(guess1)==2 and int(guess2)==1:
print(“玩家一获胜”)

你可能感兴趣的:(python小练习)