Listing 06-01: Calculation of the average

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 06\06.01 - Calculation of the average.py
# Description: Calculation of the average
##############################################################################

grades = [6, 7, 5, 8, 9]
sum = 0
x = 0
while x < 5:
    sum += grades[x]
    x += 1
print(f"Average: {sum / x:5.2f}")
Click here to download the file