Listing 06-02: Calculation of the average with entered grades

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

grades = [0, 0, 0, 0, 0]
sum = 0
x = 0
while x < 5:
    grades[x] = float(input(f"Grade {x}:"))
    sum += grades[x]
    x += 1
x = 0
while x < 5:
    print(f"Grade {x}: {grades[x]:6.2f}")
    x += 1
print(f"Average: {sum / x:5.2f}")
Click here to download the file