码迷,mamicode.com
首页 > 其他好文 > 详细

剪刀石头布的游戏 random中randint的用法

时间:2018-08-05 00:36:09      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:pre   from   模块   dom   imp   and   游戏   input   用法   

#-*- cording: utf-8 -*-
from random import randint
player = int(input("0为剪刀 1为拳头 2为布"))
computer = randint(0,2)

if (player == "0" and computer == "2") or (player == "1" and computer =="0") or (player == "2" and computer == "0"):
    print("你赢了")
elif player == computer:
    print("平局")
else:
    print("你输了!")

random模块中randint的用法是()中输入数字,会随机出现其中的数字。

剪刀石头布的游戏 random中randint的用法

标签:pre   from   模块   dom   imp   and   游戏   input   用法   

原文地址:https://www.cnblogs.com/zmw-1997/p/9420496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!