Unit 1 Session 2 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Calculate the average of a list of integer scores.
0) Remember that average can be calculated using (sum of values / number of values)
1) Create a variable to store the sum
2) Loop through the list, and add each value to the sum variable
3) Divide the sum variable by the length of the list and return the result
def average(scores):
total = 0
for score in scores:
total += scores
return total / len(scores)