Here, we are going to execute a python program in which we need to discover the victor of the day from given two ball groups.
There are two ball groups (Team1 and Team2) in a school and they play a few matches each day relying upon their time and intrigue. A few days they play 3 matches, a few days 2, a few days 1, and so on.
Compose a python work, find_winner_of_the_day(), which acknowledges the name of the victor of each match and returns the name of the general champ of the day. If there should arise an occurrence of the equivalent number of wins, return “Tie“.
Input : Team1 Team2 Team1 Output : Team1 Input : Team1 Team2 Team2 Team1 Team2 Output : Team2
# Python3 program to find winner of the day # function which accepts the name of winner # of each match of the day and return # winner of the day # This function accepts variable number of arguments in a tuple def find_winner_of_the_day(*match_tuple): team1_count = 0 team2_count = 0 # Iterating through all team name # present in a match tuple variable for team_name in match_tuple : if team_name == "Team1" : team1_count += 1 else : team2_count += 1 if team1_count == team2_count : return "Tie" elif team1_count > team2_count : return "Team1" else : return "Team2" # Driver Code if __name__ == "__main__" : print(find_winner_of_the_day("Team1","Team2","Team1")) print(find_winner_of_the_day("Team1","Team2","Team1","Team2")) print(find_winner_of_the_day("Team1","Team2","Team2","Team1","Team2"))
Team1 Tie Team2