Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Volleyball game
#1
I need to have user input scores for 5 volleyball games. The winner must score 25 points and win by 2. If the scores don't meet theses conditions, they need to be entered again. I keep trying different ways but can't get it completely correct.

def match(Home, Visitor, matchnum):
print("Match", str(matchnum))
scorehome = int(input("Enter the number of points "+Home+" got in Match "+str(matchnum)+": "))
scorevisitor = int(input("Enter the number of points "+Visitor+" got in Match "+str(matchnum)+": "))
return scorehome, scorevisitor
def printScoreCard(Home,Visitor,winhome,winvisitor):
print(Home,winhome)
print(Visitor, winvisitor)
def startgame():
print("Welcome to the volleyball score program.")
Home = input("Enter the home team's name: ")
Visitor = input("Enter the visitor's team name: ")
winhome = 0
winvisitor = 0
for i in range(5):
scorehome,scorevisitor=match(Home, Visitor,i+1)
if (scorehome > scorevisitor and scorehome < 25):
print("One team must score at least 25 points")
elif (scorehome > scorevisitor and scorehome - scorevisitor < 2):
print("One team must win by 2")
elif (scorevisitor > scorehome and scorevisitor < 25):
print("One team must score at least 25 points")
elif (scorevisitor > scorehome and scorevisitor - scorehome < 2):
print("One team must win by 2")
elif scorehome > scorevisitor:
winhome = winhome + 1
else:
scorevisitor > scorehome
winvisitor = winvisitor + 1
printScoreCard(Home,Visitor,winhome,winvisitor)

if winhome>winvisitor:
print(Home+" wins the game!")
else:
print(Visitor+" wins the game!")

startgame()
Reply


Messages In This Thread
Volleyball game - by DrewD - Dec-11-2017, 05:34 AM
RE: Volleyball game - by j.crater - Dec-11-2017, 06:51 AM
RE: Volleyball game - by DrewD - Dec-11-2017, 07:25 PM
RE: Volleyball game - by j.crater - Dec-11-2017, 07:44 PM
RE: Volleyball game - by DrewD - Dec-12-2017, 02:52 AM
RE: Volleyball game - by j.crater - Dec-13-2017, 06:21 AM
RE: Volleyball game - by DrewD - Dec-13-2017, 05:09 PM
RE: Volleyball game - by j.crater - Dec-13-2017, 06:49 PM
RE: Volleyball game - by DrewD - Dec-14-2017, 07:23 PM
RE: Volleyball game - by DrewD - Dec-15-2017, 03:06 AM
RE: Volleyball game - by j.crater - Dec-16-2017, 09:41 AM
RE: Volleyball game - by DrewD - Dec-17-2017, 04:15 AM
RE: Volleyball game - by Terafy - Dec-17-2017, 04:48 AM
RE: Volleyball game - by Terafy - Dec-17-2017, 05:39 AM
RE: Volleyball game - by DrewD - Dec-17-2017, 07:28 PM
RE: Volleyball game - by Terafy - Dec-17-2017, 07:59 PM
RE: Volleyball game - by DrewD - Dec-17-2017, 08:22 PM
RE: Volleyball game - by Terafy - Dec-17-2017, 08:28 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020