+ 1
Types
Can anyone tell me why notas[i] are printing integer values? notas = [] qnotas = int(input('Quantidade de notas: ')) i = 0 soma = 0 while i < qnotas: k = float(input('%iª nota: '%(i+1))) notas.append(k) soma = soma + notas[i] i+=1 i = 0 while i < qnotas: print ('%iª nota: %.f'%((i+1),notas[i])) i+=1 media = soma/qnotas print('Média final: %.f'%media)
1 Resposta
+ 1
In the final print statement do
print('Média final: %f'%media)
or
print('Média final: {0}'.format(media))
instead of doing
print('Média final: %.f'%media).
The statement that you have used is removing the numbers after decimal point because you have used a '.' after the '%' symbol.