write a Python program that reads information about all the matches and compile the following statistics for each player: Number of best-of-5 set matches won Number of best-of-3 set matches won Number of sets won Number of games won Number of sets lost Number of games lost | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
- 1

write a Python program that reads information about all the matches and compile the following statistics for each player: Number of best-of-5 set matches won Number of best-of-3 set matches won Number of sets won Number of games won Number of sets lost Number of games lost

Here are some basic facts about tennis scoring: A tennis match is made up of sets.  A set is made up of games. To win a set, a player has to win 6 games with a difference of 2 games.  At 6-6, there is often a special tie-breaker.  In some cases, players go on playing till one of them wins the set with a difference of two games. Tennis matches can be either 3 sets or 5 sets.  The player who wins a majority of sets wins the match (i.e., 2 out 3 sets or 3 out of 5 sets) The score of a match lists out the games in each set, with the overall winner's score reported first for each set.  Thus, if the score is 6-3, 5-7, 7-6 it means that the first player won the first set by 6 games to 3, lost the second one 5 games to 7 and won the third one 7 games to 6 (and hence won the overall match as well by 2 sets to 1). we will read input from the keyboard (standard input) containing the results of several tennis matches.  Each match's score is recorded on a separate line with the following format: Winner:Loser:Set-1-score,...,Set-k-score, where 2 <= k <= 5 we should print out to the screen (standard output) a summary in decreasing order of ranking, where the ranking is according to the criteria 1-6 in that order (compare item 1, if equal compare item 2, if equal compare item 3 etc, noting that for items 5 and 6 the comparison is reversed). we can assume that there are no spaces around the punctuation marks ":", "-" and ",".  Each player's name will be spelled consistently and no two players have the same name.

25th Aug 2016, 10:50 AM
Gaurav Kumar Tiwari
Gaurav Kumar Tiwari - avatar
8 Antworten
0
Why don't you write it?
25th Aug 2016, 2:08 PM
Ezie
0
I tried. BT didn't worked
25th Aug 2016, 2:10 PM
Gaurav Kumar Tiwari
Gaurav Kumar Tiwari - avatar
0
and if I knew than y would I ask here.
25th Aug 2016, 2:11 PM
Gaurav Kumar Tiwari
Gaurav Kumar Tiwari - avatar
0
any one comment the code
27th Aug 2019, 7:31 PM
SAnJAy Gopi krishnan
SAnJAy Gopi krishnan - avatar
0
This is the question of Week 5 programming assignment of Programming, Data structure and algorithms using python. Just refer to this video and it will explain the logic as well as coding behind the tennis problem. It will help you to pass all the public and private cases and get you 100.0 / 100.0 in assignment. link to video : https://youtu.be/q1zfnE7puL8 Hope it will help you.
1st Sep 2019, 7:17 AM
Deep Patel
Deep Patel - avatar
0
data=input() result={} while data: (winner,loser,sets)=data.split(':') (winner_sets,loser_sets)=(0,0) (winner_games,loser_games)=(0,0) (winner_BO5,winner_BO3)=(0,0) for set in sets.split(','): temp=set.split('-') temp[0]=int(temp[0]) temp[1]=int(temp[1]) if(temp[0]>temp[1]): winner_sets=winner_sets+1 else: loser_sets=loser_sets+1 winner_games=winner_games+temp[0] loser_games=loser_games+temp[1] if winner_sets >=3: winner_BO5=winner_BO5+1 elif winner_sets <3: winner_BO3=winner_BO3+1 for player in [winner,loser]: try: result[player] except: result[player]=[0,0,0,0,0,0] if player == winner: result[player][0]=result[player][0]+winner_BO5 result[player][1]=result[player][1]+winner_BO3 result[player][2]=result[player][2]+winner_sets result[player][3]=result[player][3]+winner_games result[player][4]=result[player][4]+loser_sets result[player][5]=result[player][5]+loser_games if player==loser: result[player][2]=result[player][2]+loser_sets result[player][3]=result[player][3]+loser_games result[player][4]=result[player][4]+winner_sets result[player][5]=result[player][5]+winner_games data=input() result=sorted(result.items(),key=lambda t:t[1],reverse=True) for element in result: print(element[0],element[1][0],element[1][1],element[1][2],element[1][3],element[1][4],element[1][5]) #Indentations must be followed strictly else the whole program result changes #coded by Lakshmi Narayana Naidu
1st Sep 2019, 4:55 PM
Lakshmi Narayana Naidu
Lakshmi Narayana Naidu - avatar
6th Mar 2018, 8:48 PM
Mitkumar Patel
Mitkumar Patel - avatar
27th Aug 2019, 5:18 PM
Sakshi Gupta
Sakshi Gupta - avatar