-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytexe (34).py
43 lines (37 loc) · 938 Bytes
/
pytexe (34).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# testexec.py
def entnotas(qtd):
lista=[]
for i in range(qtd):
nota=int(input("Insira a nota do aluno:"))
lista.append(nota)
return lista
def freqabsoluta(lst):
i=0; lista=[0,0,0,0,0,0,0,0,0,0,0];
for i in range(len(lst)):
lista[lst[i]] += 1
return lista
def freqrelativa(lst):
lista=freqabsoluta(lst)
lista2=[]
for i in lista:
x=i/len(lst)
lista2.append(x)
return lista2
def imprimeTabela(notas, freqA, freqR):
print("________________________")
print("| NOTAS |FREQ A | FREQ R| ")
print("________________________")
for i in range(11):
print("| {:>5.0f} | {:>5.2f} | {:>5.2f} |".format(i, freqA[i], freqR[i]))
print("________________________")
def main():
qtd=2
nota=entnotas(qtd)
frequenciaA=freqabsoluta(nota)
frequenciaR=freqrelativa(nota)
imprimeTabela(nota, frequenciaA, frequenciaR)
if __name__ == '__main__':
main()