设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 33027|回复: 0
打印 上一主题 下一主题

【Python 第28课】 字符串的分割

[复制链接]

0

主题

0

好友

215

积分

中级会员

Rank: 3Rank: 3

楼主
发表于 2015-4-22 16:17:46 |显示全部楼层
  1. from random import choice

  2. s = [0,0]
  3. direction = ['left','center','right']

  4. def kick():
  5.     print '===You Kick!==='
  6.     print 'choose one side to shoot:'
  7.     print 'left,center,right'
  8.     you = raw_input()
  9.     print 'You kicked' + you
  10.     com = choice(direction)
  11.     print 'computer saved' + com
  12.     if you != com:
  13.         print 'Goal!'
  14.         s[0] += 1
  15.     else:
  16.         print 'Oops...'
  17.     print 'score: %d(you) - %d(com)\n' % (s[0],s[1])

  18.     print '===You Save!==='
  19.     print'choose one side you save:'
  20.     print'left,center,right'
  21.     you = raw_input()
  22.     print 'you saved' + you
  23.     com = choice(direction)
  24.     print 'computer kicked' + com
  25.     if you == com:
  26.         print 'saved'
  27.     else:
  28.         print'Oop...'
  29.         s[1] += 1
  30.     print 'score: %d(you) - %d(com)\n' % (s[0],s[1])

  31. for i in range(1):
  32.     print '===Round %d ===' %(i+1)
  33.     kick()

  34. while (s[0] ==s[1]):
  35.     i +=1
  36.     print '===Round %d ===' % (i+1)
  37.     kick()

  38. if s[0] > s[1]:
  39.     print 'You Win!'
  40. else:
  41.     print 'You Lose.'
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-6-1 17:54 , Processed in 0.021849 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部