Python实践课-点球大战

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!'

你可能感兴趣的:(Python实践课-点球大战)