您当前的位置: 首页 >  游戏

哆啦A梦_i

暂无认证

  • 1浏览

    0关注

    629博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Python:01猜拳游戏&&火车检票入站(if多重分支/嵌套)

哆啦A梦_i 发布时间:2019-10-01 10:52:26 ,浏览量:1

#游戏一:猜拳游戏(if多重分支)
import random
playerInput=int(input("请输入(0剪刀,1石头,2布):"))
compter=random.randint(0,2)
if(playerInput==0 and compter==2) or\
        (playerInput==1 and compter==0) or\
        (playerInput==2 and compter==0):
    print("电脑出拳%s,恭喜你赢了!"%compter)
elif (playerInput==0 and compter==0) or \
        (playerInput==1 and compter==1) or\
        (playerInput==2 and compter==2):
    print("电脑出拳%s,平局!"%compter)
else:
    print("电脑出拳%s,很遗憾你输了!" % compter)

#游戏二:火车检票入站(if嵌套)
tikcet=int(input("请输入(1表示有车票,0表示没车票):"))
safe=int(input("请输入(1表示没带危险物品,0表示带了危险物品):"))
if tikcet==1:
   if safe==1:
       print("通过安检,可以上车!")
   else:
       print("你携带了违规物品,没通过安检,不能上车!")
else:
    print("没有车票,不能进站!")

 

关注
打赏
1556978864
查看更多评论
立即登录/注册

微信扫码登录

0.0767s