- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

# Python program to find average score of each students from dictionary of scores

Suppose we have a dictionary of students marks. The keys are names and the marks are list of numbers. We have to find the average of each students.

So, if the input is like scores = {'Amal' : [25,36,47,45],'Bimal' : [85,74,69,47],'Tarun' : [65,35,87,14],'Akash' : [74,12,36,75]}, then the output will be [38.25, 68.75, 50.25, 49.25] so 38.25 is average score for Amal, 68.75 is average score for Bimal and so on.

To solve this, we will follow these steps −

- avg_scores := a new map
- for each name in scores dictionary, do
- avg_scores[name] := average of scores present in the list scores[name]

- return list of all values of avg_scores

## Example

Let us see the following implementation to get better understanding

def solve(scores): avg_scores = dict() for name in scores: avg_scores[name] = sum(scores[name])/len(scores[name]) return list(avg_scores.values()) scores = {'Amal' : [25,36,47,45],'Bimal' : [85,74,69,47],'Tarun' : [65,35,87,14],'Akash' : [74,12,36,75]} print(solve(scores))

## Input

[['Amal',37],['Bimal',37],['Tarun',36],['Akash',41],['Himadri',39]]

## Output

[38, 68, 50, 49]

- Related Articles
- Python program to find word score from list of words
- Program to find maximum score from removing stones in Python
- Python program to get maximum of each key Dictionary List
- Rahul Dravid scores 63 runs in his 12th innings, thereby his average score increased by 2. What will be his average score after 12th innings ?
- Program to find maximum score from performing multiplication operations in Python
- How to find the average of non-zero values in a Python dictionary?
- Python program to find runner-up score
- Python program to find score and name of winner of minion game
- Program to find minimum difference of stone games score in Python
- Program to find maximum score of brick removal game in Python
- Program to find maximum score of a good subarray in Python
- Python program to find the sum of dictionary keys
- 8 scores of bananas cost Rs. 192. Find the cost of 85 bananas. [Hint: 1 score \( =20] \)
- Aggregation framework to get the name of students with test one score less than the total average of all the tests
- Program to find the maximum score from all possible valid paths in Python

Advertisements