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

single

bookChallenge: Calculate and Print Averages

Glissez pour afficher le menu

Tâche

Glissez pour commencer à coder

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 desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 4
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt