
Cricket Game
By: a guest on
Apr 22nd, 2012 | syntax:
None | size: 1.68 KB | hits: 111 | expires: Never
teama_score = 0
teamb_score = 0
overlimit = 0
wickets_teama = 0
wickets_teamb = 0
def main():
"""This is the main function's docstring"""
print('Welcome to the Cricket Scoreboard Calculator')
print('Follow the prompts below to find out who wins!')
print('Team A to bat first')
teama_loop()
print('Okay, Team B is now in to bat')
teamb_loop()
print('Team A scored', teama_score, 'runs and lost', wickets_teama, 'wickets')
print('Team B scored', teamb_score, 'runs and lost', wickets_teamb, 'wickets')
if teama_score < teamb_score:
print('Team B wins by', teamb_score - teama_score, 'runs')
else:
print('Team A wins by', teama_score - teamb_score, 'run/s')
def teama_loop():
"""This is Team A's docstring"""
global teama_score
overlimit = int(input('How many overs are to be played?: '))
print('Okay good luck Team A with', overlimit, 'overs')
for overs in range(overlimit):
for balls in range(6):
number = int(input('Enter runs or "W" for wicket: '))
teama_score = teama_score + number
print('The run total for Team A is', teama_score)
return teama_score
def teamb_loop():
"""This is Team B's docstring"""
global teamb_score
overlimit = int(input('How many overs are to be played?: '))
for overs in range(overlimit):
for balls in range(6):
number = int(input('Enter runs or "W" for wicket: '))
teamb_score = teamb_score + number
print('The run total for Team B is', teamb_score)
if teamb_score > teama_score:
break
return teamb_score
main()