Doubts average calculation with Python 3.5

-2

I am creating a program, using Python 3.5, to calculate average, but in my school there are some subjects with two teachers, and each one of a different proof.

The problem is that the code I created does the average of (Prova 1 + Prova 2)/2 , which is equal to media1 , (Atividade 1 + Atividade 2)/2 , which is equal to average 2, and the final average is with% and when it is a matter I do not put anything in P2 gives error. I was thinking, when the user enter the name of the subject run such code, and another name, another code, how do I do that?

My code:

nota1 = float(input("Nota1: "))

nota2 = float(input('Nota 2: '))

simulado = float(input('Nota simulado: '))

ac1 = float(input('Nota AC1: '))

ac2 = float(input('Nota AC2: '))


media1 = (nota1+nota2)/2
mediaAC = (ac1+ac2)/2
mediaf = (media1+simulado+mediaAC)/3 

print (mediaf)

if mediaf == 6:
   print("na media")


if mediaf < 6:
   print("abaixo da media")
    
asked by anonymous 22.04.2016 / 03:31

2 answers

2
from functools import partial

notas = list(map(float,list(iter(partial(input, 'Nota: '), ''))))
ac = list(map(float,list(iter(partial(input, 'AC: '), ''))))
simulado = float(input('Nota simulado: '))

media_notas = sum(notas)/len(notas)
media_ac = sum(ac)/len(ac)
media_final = (media_notas + media_ac + simulado) / 3 


print('medias: ', media_notas, media_ac, media_final)

if media_final >= 6:
    print('na media')
else:
    print('abaixo da media')

In this way you enter as many notes as necessary, until the value of the note is empty (enter 'Enter'). Example:

$ python notas.py 
Nota: 5
Nota: 10
Nota: 
AC: 5
AC: 5
AC: 
Nota simulado: 10
notas:  7.5 5.0 7.5
na media
    
22.04.2016 / 14:42
1

Oops! Dude, I'm a beginner but I tried to implement a solution for you:

qtd_notas = int(input("Digite a quantidade de notas: "))
notas = 0
for i in range(0, qtd_notas):
    notas += input("Digite a nota " + str(i + 1) + ": ")

media = notas / qtd_notas

simulado = input("Nota Simulado: ")

acs = 0

for i in range(0, qtd_notas):
    acs += input("Notas AC" + str(i + 1) + ": ")

media_ac = acs/qtd_notas

media_final = (media + simulado + media_ac) / 3

print (media_final)

if media_final == 6:
    print ("na media")
if media_final < 6:
    print ("abaixo da media")

What I did was put in the beginning, the user enter the amount of notes that will compose the averages. Ignore the variables.

I hope I have helped.

    
22.04.2016 / 05:55