Answer to Question #253592 in Python for Pooja

Question #253592

IPL Match Details

Write a program that reads all the match outcomes and summarizes the information of all the matches.

Points are given to the teams based on the outcome of the match.

A win earns a team 3 points. A draw earns 1. A loss earns 0.

The following information is expected:

MP: Matches Played

W: Matches Won

D: Matches Drawn (Tied)

L: Matches Lost

P: Points



1
Expert's answer
2021-10-20T02:49:25-0400
matches_st = {}
while True:
	inp = input('enter march result or -1 to continue:\n')
	if inp == "-1":
		break
	else:
		match = inp.split()
		if match[2].lower() == 'win':
			score = [3,0]
		elif match[2].lower() == 'loss':
			score = [0,3]
		else:
			score = [1,1]
		for i in range(2):
			com = match[i]
			if com in matches_st:
				tmp = matches_st[com]
			else:
				tmp = [0,0,0,0,0]
			tmp[0] += 1
			if score[i] == 3:
				tmp[1] += 1
			elif score[i] == 1:
				tmp[2] += 1
			else:
				tmp[3] += 1
			tmp[4] += score[i]
			matches_st[com] = tmp
for command in matches_st:
	print(
		f'''
T: {command}
MP: {matches_st[command][0]}
W: {matches_st[command][1]}
D: {matches_st[command][2]}
L: {matches_st[command][3]}
P: {matches_st[command][4]}''')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS