+ 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 Answer
+ 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.