Created
July 8, 2016 05:25
-
-
Save rajasimon/58229fab7ab31a1deedcce0ae4b411dc to your computer and use it in GitHub Desktop.
Enter Volleyball score and get the winner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
class VolleyBall: | |
def __init__(self): | |
# score | |
self.team_one = 0 | |
self.team_two = 0 | |
self.no_of_matches = 5 | |
def get_user_input(self, match_count): | |
score_one = int(raw_input("Match {} Team 1 :>".format(match_count))) | |
score_two = int(raw_input("Match {} Team 2 :>".format(match_count))) | |
return score_one, score_two | |
if __name__ == "__main__": | |
volleyball = VolleyBall() | |
match_counter = 0 | |
while match_counter < volleyball.no_of_matches: | |
# Get the score from user | |
score_one, score_two = volleyball.get_user_input(match_counter + 1) | |
volleyball.team_one += score_one | |
volleyball.team_two += score_two | |
match_counter += 1 | |
# Result | |
if volleyball.team_one > volleyball.team_two: | |
print("Team 1 is winner") | |
else: | |
print("Team 2 is winner") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment