Advertisement
Guest User

Cricket Game

a guest
Apr 22nd, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement