python program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

python program

The input is terminated by a blank line. You have to write a Python program that reads information about all the matches and compile the following statistics for each player: 1. Number of best-of-5 set matches won 2. Number of best-of-3 set matches won 3. Number of sets won 4. Number of games won 5. Number of sets lost 6. Number of games lost You 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). For instance, given the following data Djokovic:Murray:2-6,6-7,7-6,6-3,6-1 Murray:Djokovic:6-3,4-6,6-4,6-3 Djokovic:Murray:6-0,7-6,6-7,6-3 Murray:Djokovic:6-4,6-4 Djokovic:Murray:2-6,6-2,6-0 Murray:Djokovic:6-3,4-6,6-3,6-4 Djokovic:Murray:7-6,4-6,7-6,2-6,6-2 Murray:Djokovic:7-5,7-5 Williams:Muguruza:3-6,6-3,6-3 your program should print out the following Djokovic 3 1 13 142 16 143 Murray 2 2 16 143 13 142 Williams 0 1 2 15 1 12 Muguruza 0 0 1 12 2 15 You 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.

7th Mar 2017, 1:55 PM
sangeetha sheeba
sangeetha sheeba - avatar
8 Answers
+ 2
is this homework?
7th Mar 2017, 2:12 PM
LordHill
LordHill - avatar
+ 1
please help me to solve this problem
7th Mar 2017, 1:55 PM
sangeetha sheeba
sangeetha sheeba - avatar
+ 1
we don't help with homework, but if you have code to show we will help work thru errors
7th Mar 2017, 2:30 PM
LordHill
LordHill - avatar
+ 1
my program fails to verify with test cases def setswon(s): m = len(s) count = 0 for i in range(0, m, 4): if s[i] > s[i + 2]: count += 1 print(count) def setslost(s): m = len(s) count = 0 for i in range(0, m, 4): if s[i] < s[i + 2]: count += 1 print(count) def gameswon(s): m = len(s) won = 0 for i in range(0, m, 4): won = won, s[i] print(won) def gameslost(s): m = len(s) lost = 0 for i in range(2, m, 4): lost = lost, s[i] print(lost) players = dict() contents = list() from sys import stdin for line in stdin: if line == "\n": break else: contents.append(line) count15 = 0 count25 = 0 count13 = 0 count23 = 0 p = 0 q = 0 r = 0 s = 0 x = [] y = [] player1, player2, score = line.split(':') if len(score) <= 12: count15 = 1 count25 = 0 elif len(score) <= 12: count13 = 0 count23 = 0 p = setswon(score) q = setslost(score) r = gameswon(score) s = gameslost(score) x = [count15, count13, p, r, q, s] y = [count25, count23, q, s, p, r] if not players == '{}': players[player1] = x players[player2] = y else: for value in players.keys(): if player1 == value: players[value][0] += 1 players[value][1] += 1 players[value][2] += 1 players[value][3] += 1 players[value][4] += 1 players[value][5] += 1 elif player2 == value: players[value][0] += 1 players[value][1] += 1 players[value][2] += 1 players[value][3] += 1 players[value][4] += 1 players[value][5] += 1 else: players[player1] = x players[player2] = y
8th Mar 2017, 2:59 PM
venkhatesh arunachalam
venkhatesh arunachalam - avatar
0
It's not a home work
7th Mar 2017, 2:59 PM
sangeetha sheeba
sangeetha sheeba - avatar
0
I can't complete the program. I have try to separate the input into several values.But I can"t calculate it for result.
7th Mar 2017, 3:08 PM
sangeetha sheeba
sangeetha sheeba - avatar
0
It's very urgent please anybody help me . I have to solve this urgently. Trust me it's not a homework.
7th Mar 2017, 3:24 PM
sangeetha sheeba
sangeetha sheeba - avatar
0
The input is terminated by a blank line. You have to 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 wonNumber of best-of-3 set matches wonNumber of sets wonNumber of games wonNumber of sets lostNumber of games lost You 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). For instance, given the following data Federer:Nadal:2-6,6-7,7-6,6-3,6-1 Nadal:Federer:6-3,4-6,6-4,6-3 Federer:Nadal:6-0,7-6,6-7,6-3 Nadal:Federer:6-4,6-4 Federer:Nadal:2-6,6-2,6-0 Nadal:Federer:6-3,4-6,6-3,6-4 Federer:Nadal:7-6,4-6,7-6,2-6,6-2 Nadal:Federer:7-5,7-5 Halep:Wozniacki:3-6,6-3,6-3 your program should print out the following Federer 3 1 13 142 16 143 Nadal 2 2 16 143 13 142 Halep 0 1 2 15
27th Aug 2019, 12:19 PM
Nandhini. S
Nandhini. S - avatar