设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: crossin先生
打印 上一主题 下一主题

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

[复制链接]

0

主题

0

好友

96

积分

注册会员

Rank: 2

楼主
发表于 2016-12-9 13:28:46 |显示全部楼层
  1. from random import choice
  2. bifen = [0, 0]
  3. fangxiang = ['left','middle','right']
  4. def guocheng():
  5.     print ' ==== now you kick ==== '
  6.     print ' please choose one side to shoot '
  7.     print ' left , middle , right '
  8.     you = raw_input()
  9.     print 'you kicked ' + you
  10.     com = choice(fangxiang)
  11.     print ' the other side saved ' + com
  12.     if you != com:
  13.         print ' he missed the ball , you win '
  14.         bifen[0] += 1
  15.     else:
  16.         print ' he got the ball , you lose \n'
  17.     print ' you - com\n %d -%d\n'%(bifen[0],bifen[1])

  18.     print ' ==== now you save ===='
  19.     print ' plese choose one side to save '
  20.     print ' left , middle , right '
  21.     you = raw_input()
  22.     print ' you saved ' + you
  23.     com = choice(fangxiang)
  24.     print ' the other side kicked ' + com
  25.     if you != com:
  26.         print ' you missed the ball , you lose '
  27.         bifen[1] += 1
  28.     else:
  29.         print ' you got the ball , you win '
  30.     print ' you - com\n %d -%d\n'%(bifen[0],bifen[1])
  31. for i in range(5):
  32.     print ' ==== round %d ==== '%( i +1 )
  33.     guocheng()
  34.     while bifen[0] == bifen[1]:
  35.         i += 1
  36.         print' round %d'%(i + 1 )
  37.         guocheng()
  38.     if bifen[0] >bifen[1]:
  39.         print ' you win '
  40.     else:
  41.         print ' you lose '
  42.    
复制代码
回复

使用道具 举报

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

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

GMT+8, 2024-5-17 23:00 , Processed in 0.024829 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部