Section 1. Chapter 4
single
Challenge: Calculate and Print Averages
Swipe to show menu
Task
Swipe to start coding
Write a function that calculates and prints the average of a given list of numbers.
- Calculate the sum of all numbers in the
numberslist. - Determine the number of elements in the
numberslist. - If the list is empty, set the average to 0.
- Otherwise, divide the sum by the number of elements to get the average.
- Print a message displaying the calculated average.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat