Calculate average with final exam if I fail standard grades

Asked

Viewed 850 times

0

  1. Read the values of four bimonthly school grades of a student represented by the variables N1,N2,N3,N4. Calculate the arithmetic mean (variable MD1) of that student and display the message "Approved with average' if the average obtained is greater than 7.0; otherwise the program must request the fifth exam grade, represented by NE) and calculate a new, variable (MD2) average between the exam grade and the first average. If the average value is greater than or equal to 5, display the message "Approved with average"; otherwise display the message "Disapproved with average". Display the average value next to each message.

Here was the solution I found:

# mudei as variaveis e a quantidade de notas, mas a essencia é a mesma. do que foi pedido.

a = float(input('Nota 1: '))
b = float(input('Nota 2: '))
c = float(input('nota 3: '))
m1 = (a + b) / 2
if m1 >= 7:
    print('Aprovado media %f' % m1)
else:
    m2 = (m1 + c) / 2
    if m2 >= 5:
        print('Aluno aprovado media %f' % m2)
    else:
        if m2 < 4:
            print('Reprovado media %f' % m2)
enter = input('\nPressione <ENTER> para encerrar...')

Such a solution would be satisfactory?

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

3

Right away it’s not right because the exercise calls for 4 notes and you only ask for 3 and divide by 2 I don’t know why (I don’t know what better to expect doing this wrong, if it saves typing some characters, only caused confusion)then begins to do something completely meaningless and that is not what the statement asks (must ask for another note). Variable names don’t really matter much.

I think the formula to catch the new average can’t use the old average dividing by 2 because it passes give more weight to the new note, but it’s what the statement asks, so come on.

I did not worry about a possible typo that would break the application, the correct thing is to treat it.

a = float(input('Nota 1: '))
b = float(input('Nota 2: '))
c = float(input('nota 3: '))
d = float(input('nota 4: '))
m1 = (a + b + c + d) / 4
if m1 >= 7:
    print('Aprovado media %f' % m1)
else:
    e = float(input('nota exame: '))
    m2 = (m1 + e) / 2
    if m2 >= 5:
        print('Aluno aprovado media %f' % m2)
    else:
        print('Reprovado media %f' % m2)

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

  • Yes, friend, I am aware that the resolution proposed by me is different from that. And that is exactly why I asked for a comment in the resolution I made, explaining that it was different but that the central idea was the same. But I get it. And thank you for helping.

  • If the student did not pass with the regular grades having an average of 7, divide the grade obtained by 2 and then he will make a super proof screwed to try to save himself worth half the grade of the semester, but then the average is 5. In college I graduated (UFMT) was exactly like this.

  • @Victorstafusa is, there are these, I’ve seen the proof of salvation replace everything that was worth in the semester, that is, it was riskier (not so much because it was known that it was easier), but it was less work just to do it. It was a kind of virtual recovery since it did not have reinforcement class, alias I never saw it serious, even in German school all straight recovered the real student, it was only a punishment (to attend more classes and do a lot of work at home) for those who did not have normal grade and another chance to have the grade.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.