Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Calculate and Print Averages | Automating Tasks with Python
Automating System Tasks with Python: A Beginner's Guide
Section 1. Chapter 4
single

single

bookChallenge: 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 numbers list.
  • Determine the number of elements in the numbers list.
  • 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

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt