-5
I made a code that stores data in a dictionary, and the dictionary is stored in a list, but when I try to add and divide the values, the first average is the one that ends up being valid for all students.
print('RU do aluno: - ')
alunos = []
notas = []
N = int(input('Qual o número de alunos? '))
for i in range(N):
boletim = {'nome' : 0, 'n1' : 0, 'n2' : 0, 'n3' : 0, 'n4' : 0, 'media' :0}
boletim['nome'] = input('Digite o nome do aluno: ')
boletim['n1'] = float(input('Digite a primeira nota: '))
boletim['n2'] = float(input('Digite a segunda nota: '))
boletim['n3'] = float(input('Digite a terceira nota: '))
boletim['n4'] = float(input('Digite a quarta nota: '))
boletim ['media'] = boletim ['n1'], boletim ['n2'], boletim ['n3'], boletim ['n4']
alunos.append(boletim)
notas.append(boletim['media'])
soma_das_notas = 0
for nota in notas[0]:
soma_das_notas += nota
boletim['media'] = soma_das_notas / 4
if boletim['media'] >= 7:
boletim['media'] = 'aprovado'
else:
boletim['media'] = 'reprovado'
print('\nNota dos alunos')
print('-' * 90)
for aluno in alunos:
print(f'{aluno["nome"]} {aluno["n1"]} {aluno["n2"]} {aluno["n3"]} {aluno["n4"]} {aluno["media"]}')
He returns to me the following:
I would consider exchanging this data structure see that example
– Augusto Vasques