Instructions
Objective
Write a program team class implementation in python.
Requirements and Specifications
Source Code
class Team:
def __init__(self):
self.team_name = 'none'
self.team_wins = 0
self.team_losses = 0
def get_win_percentage(self):
total = self.team_wins + self.team_losses
if total > 0:
return self.team_wins / total
return 0.0
def main():
team = Team()
name = input('Please, enter team name: ')
wins = int(input('Please, enter team wins: '))
losses = int(input('Please, enter team losses: '))
team.team_name = name
team.team_wins = wins
team.team_losses = losses
if team.get_win_percentage() >= 0.5:
print('Congratulations, Team ' + team.team_name + ' has a winning average!')
else:
print('Team ' + team.team_name + ' has a losing average.')
if __name__ == '__main__':
main()