您的位置:首页 > 编程语言 > Python开发

Python基础-实践课之点球大战

2016-04-25 18:37 549 查看
mark:2016-04-25

#coding=utf-8
import time
from random import choice
#define a list to store the result
result = [0,0]
#define two funcation
orientation =['1','2','3','4','5']
def kick():
print '===Round %d -you kick!==='%(i+1)
print 'choose the kick orientation '
player_orientation = raw_input()
print 'Computer is saving goal........'
time.sleep(1)
computer_orientation = choice(orientation)
if player_orientation != computer_orientation:
print 'GOAL!!!'
result[0]= result[0] + 1
else:
print 'WTF! 居然没中!'
print 'Your Score:%d \nComputer Score:%d'%(result[0],result[1])

print '===Round %d -you Save!==='%(i+1)
print 'Computer is kick ball........'
time.sleep(1)
computer_orientation = choice(orientation)
print 'choose the save orientation '
player_orientation = raw_input()
if player_orientation == computer_orientation:
print 'Nice!Save Success!'
else:
print 'WTF! '
result[1] = result[1]+1
print 'Your Score:%d \nComputer Score:%d'%(result[0],result[1])
for i in range(5):
kick()

while(result[0] == result[1]):
print '===Round %d -you kick!==='%(i+1)
kick()
if result[0] > result[1]:
print "you win!"
else:
print 'you lose!'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: