-1
I need your help to solve an issue of my programming course, I have an initial activity and do not know where to continue, I need to create a program that gets 2 grades, disappear and divide by two generating the average. (I managed to do this) Now I need to implement the program if the student has the average less than 6 the program should request that a new test be done (I was able to print this message if the if is less than 6) only after this message it should give the following actions:
Action 1 if Note 3 is greater than Note 1 replaces Note 1 and sums up and divides with the rest.
Action 2 if note 3 is greater than note 2 replace note 2 and add and divide with the rest.
Action 3 if grade 3 is less than the two grades, display the failed student message.
Follow my code, I’m lost to be able to carry out these actions.
def main ():
nome = input('Nome do Aluno: ')
ra = input('RA do aluno: ')
print('Inserir notas de "0 a 10.0"')
nota1 = float(input('Prova 1: '))
nota2 = float(input('Prova 2: '))
media = (nota1 + nota2) / 2
if media > 6.0:
print('O aluno ' , nome, 'de RA' , ra, 'foi Aprovado com a média ', media)
else:
nota3 = float(input('Aluno não passou, favor insirir nota da prova 3: '))
maior1 = nota3
if maior1 < nota1:
maior1 = nota1
if maior1 < nota2:
maior1 = nota2
if maior1 == nota3:
if nota1 >= nota2:
maior2 = nota1
else:
maior2 = nota2
if maior1 == nota2:
if nota1 >= nota3:
maior2 = nota1
else:
maior2 = nota3
if maior1 == nota1:
if nota2 >= nota3:
maior2 = nota2
else:
maior2 = nota3
media = (maior1 + maior2)/2
if media>= 6.00:
print('O aluno ', nome, 'de RA ', ra, 'foi Aprovado com a média ', media, )
else:
print('O aluno ', nome, 'de RA ', ra, 'foi Reprovado com a média ', media, )
main ()
I thank you in advance for your help!
I believe you reversed the comparisons in your
if
withnota3
and the last condition must beif nota3 < nota1 and nota3 < nota2
– anonimo
I created a few more command lines, but I still face problems with the code. in the validation part
– victor Pafume
In the
else
is not to inform a condition. Thiselif media<6:
has no sense because it will only be executed ifmedia >= 6.0
.– anonimo
Well, I took a look and did not understand why the function, try to take it (if it is not requirement of exercise); has the reversed signs of conditions, as already commented; the first print after the condition is with the third note enclosed and will not read, will give error (I say from what I know so far, despite being a beginner); the last 2 prints are for the same thing, take one, ah and remember to indent in the right condition. See if it works there.
– Raissa