Answer to Question #340885 in Python for Kaira

Question #340885

2. Assume that you are given a dictionary called softball_scoresthat holds player names as key and their scores for a season as the corresponding value.

a. Write Python code that finds and displays the lowest score in the dictionary.

b. Display the name of the player who has the lowest score.


1
Expert's answer
2022-05-14T16:39:22-0400
softball_scores = {'name 1': 10, 'name 2': 15, 'name 3': 30}
lowest_score = None
player_name = ''
for name in softball_scores:
	if lowest_score is not None:
		if softball_scores[name] < lowest_score:
			player_name = name
			lowest_score = softball_scores[name]
	else:
		player_name = name
		lowest_score = softball_scores[name]


print(f'the lowest score in the dictionary:           {lowest_score}')
print(f'the name of the player with the lowest score: {player_name}')

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