码迷,mamicode.com
首页 > 编程语言 > 详细

python小游戏(剪刀石头布)

时间:2018-01-17 01:04:34      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:port   python   random   imp   int   石头   小游戏   dom   utf8   

#!/usr/bin/python
#-- coding: utf8--
import random #导入随机数的模块

computer = random.choice([‘石头‘, ‘剪刀‘, ‘布‘])
player = raw_input(‘请出拳(石头/剪刀/布): ‘)

print "Your choice: %s, Computer‘s choice: %s" % (player, computer)
if player == ‘石头‘:
if computer == ‘石头‘:
print ‘平局‘
elif computer == ‘剪刀‘:
print ‘You WIN!!!‘
else:
print ‘You LOSE!!!‘
elif player == ‘剪刀‘:
if computer == ‘石头‘:
print ‘You LOSE!!!‘
elif computer == ‘剪刀‘:
print ‘平局‘
else:
print ‘You WIN!!!‘
else:
if computer == ‘石头‘:
print ‘You WIN!!!‘
elif computer == ‘剪刀‘:
print ‘You LOSE!!!‘
else:
print ‘平局‘

python小游戏(剪刀石头布)

标签:port   python   random   imp   int   石头   小游戏   dom   utf8   

原文地址:http://blog.51cto.com/13460572/2061767

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