In one exercise I replied with this code:
qntd_alunos = int(input("Digite a quantidade de alunos: "))
qnt = 0
while qnt <= qntd_alunos-1:
MB1 = float(input("Digite a média do primeiro bimestre: "))
MB2 = float(input("Digite a média do segundo bimestre: "))
media_semestral = (MB1 + MB2) / 2
if media_semestral >= 7:
print("Você foi aprovado")
print("Sua média semestral é: ", media_semestral)
else:
print("Sua média semestral é: ", media_semestral)
qnt = qnt+1
if qnt == 1:
print(qnt, "aluno já recebeu sua média, faltam", qntd_alunos - qnt)
else:
print(qnt, "alunos já receberam suas médias, faltam", qntd_alunos - qnt)
This code calculates the half-yearly average of each student in the class, sending a message only to those approved, until the last student arrives there, the program closes.
What the next exercise asks you to transform this code and make it calculate the overall average of the whole class after all the individual averages are entered the only way I found to do this was to store the sum of ALL the% % in ONE variable only and dividing this variable by media_semestral
. but I could not find a way to efficiently create this variable.