This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Cricket Game

By: a guest on Apr 22nd, 2012  |  syntax: None  |  size: 1.68 KB  |  views: 112  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. teama_score = 0
  3. teamb_score = 0
  4. overlimit = 0
  5. wickets_teama = 0
  6. wickets_teamb = 0
  7.  
  8. def main():
  9.     """This is the main function's docstring"""
  10.     print('Welcome to the Cricket Scoreboard Calculator')
  11.     print('Follow the prompts below to find out who wins!')
  12.     print('Team A to bat first')
  13.     teama_loop()
  14.     print('Okay, Team B is now in to bat')
  15.     teamb_loop()
  16.     print('Team A scored', teama_score, 'runs and lost', wickets_teama, 'wickets')
  17.     print('Team B scored', teamb_score, 'runs and lost', wickets_teamb, 'wickets')
  18.     if teama_score < teamb_score:
  19.         print('Team B wins by', teamb_score - teama_score, 'runs')
  20.     else:
  21.         print('Team A wins by', teama_score - teamb_score, 'run/s')
  22.            
  23. def teama_loop():
  24.     """This is Team A's docstring"""
  25.     global teama_score
  26.     overlimit = int(input('How many overs are to be played?: '))
  27.     print('Okay good luck Team A with', overlimit, 'overs')
  28.     for overs in range(overlimit):
  29.         for balls in range(6):
  30.             number = int(input('Enter runs or "W" for wicket: '))
  31.             teama_score = teama_score + number
  32.             print('The run total for Team A is', teama_score)
  33.     return teama_score
  34. def teamb_loop():
  35.     """This is Team B's docstring"""
  36.     global teamb_score
  37.     overlimit = int(input('How many overs are to be played?: '))
  38.     for overs in range(overlimit):
  39.         for balls in range(6):
  40.             number = int(input('Enter runs or "W" for wicket: '))
  41.             teamb_score = teamb_score + number
  42.             print('The run total for Team B is', teamb_score)
  43.             if teamb_score > teama_score:
  44.                 break
  45.     return teamb_score
  46.  
  47. main()
clone this paste RAW Paste Data