- 帖子
- 1
- 精华
- 0
- 积分
- 5
- 阅读权限
- 10
- 注册时间
- 2016-6-1
- 最后登录
- 2016-6-1
|
python入门课程26课中点球小游戏
from random import choice
score_you = 0
scroe_com = 0
direction = ['left', 'center', 'right']
for i in range(0,5):
print '==== Round %d - You Kick!====' %(i+1)
print 'Choose one side to shoot:',
print 'left, center, right'
you = raw_input()
print 'You kicked: ' + you
com = choice(direction)
print 'Computer saved ' + com
if you != com:
print 'Goal!'
score_you += 1
else:
print 'Oops..'
print 'Your Score: %d --- Computer Score: %d \n' %(score_you,scroe_com)
print '==== Round %d - You Save! ====' %(i+1)
print 'Choose one side to save:'
print 'left, center, right'
you = raw_input()
print 'You save ' + you
com = choice (direction)
print 'Computer kicked: ' + com
if you == com:
print 'saved!'
else:
print 'Oops...'
scroe_com += 1
print 'Your Score: %d --- Computer Score: %d' % (score_you,scroe_com)
这段代码怎么利用函数分离啊?? 想不到方法 没有思路.......
|
|