Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

WGU Foundations of Programming (Python) (E010) Exam - Topic 4 Question 9 Discussion

Posted by Arlean on Jun 16, 2026 at 09:20 AM

SIMULATION

Write a complete function calculate_average(grades) that takes a list of grades and returns the average as a float.

For example, calculate_average([85, 92, 78]) should return 85.0.

def calculate_average(grades):

# TODO: Calculate and return the average grade as a float

pass

Suggested Answer: A

==========

Step 1: The function receives one parameter named grades, which is a list of numbers.

Step 2: Use sum(grades) to add all the grades together.

Step 3: Use len(grades) to count how many grades are in the list.

Step 4: Divide the total by the number of grades.

Correct code:

def calculate_average(grades):

return sum(grades) / len(grades)

Example:

print(calculate_average([85, 92, 78]))

Output:

85.0


Get Premium Foundations of Programming (Python) (E010) Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
18 comments · newest first
FR
Francine 17 days ago
I’ll practice before the exam.
LA
Latrice 23 days ago
Don’t forget to return a float.
SH
Sherita 28 days ago
It’s basic math, you got this!
FR
Francine 1 month ago
I hope I remember the syntax.
LA
Latrice 1 month ago
Exactly! Use len() for count.
SH
Sherita 1 month ago
Just sum the grades, then divide.
FR
Francine 2 months ago
I’m a bit nervous.
LA
Latrice 2 months ago
I feel confident about it.
SH
Sherita 2 months ago
This question is straightforward.
SO
Sol 2 months ago
Don't forget to convert to float before returning!
TY
Ty 2 months ago
This seems too simple, there must be more to it.
AS
Ashley 2 months ago
Wait, what if the list is empty?
GI
Gilma 3 months ago
Totally agree, that's the basic formula!
PU
Pura 3 months ago
Just sum the grades and divide by the count!
SY
Sylvia 3 months ago
I feel like I should use the built-in sum function, but what if I forget how to calculate the length of the list?
MA
Marcos 3 months ago
This seems similar to that practice question about calculating the mean. I hope I can remember the exact syntax!
SA
Sabina 3 months ago
I'm not entirely sure how to handle an empty list. Do we just return 0.0 or something else?
WH
Whitney 4 months ago
I think I remember we need to sum the grades and then divide by the number of grades, right?
0/2000 characters

Save Cancel