# Je ne comprends pas (do not understand error message

#1

Bonsoir,

Voici ce que me dit la console !

function classe_moy at
0x7f6ae9f10488
A
None

Je ne comprends pas ...

Comment tout le monde s'en sort - Solution
#2

Please post your code so we can examine and test it. Thank you.

S'il vous plaÃ®t envoyer votre code afin que nous puissions examiner et tester. Je vous remercie.

#3
``````lloyd = {
"noms": "Lloyd",
"devoirs": [90.0, 97.0, 75.0, 92.0],
"quiz": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"noms": "Alice",
"devoirs": [100.0, 92.0, 98.0, 100.0],
"quiz": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"noms": "Tyler",
"devoirs": [0.0, 87.0, 75.0, 22.0],
"quiz": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

def moyenne(nombres):
somme = sum(nombres)
somme = float(somme)
taille = len(nombres)
taille = float(taille)
total = somme/taille

def calcule_moyenne(etudiant):
devoirs = average(etudiant['devoirs'])
quiz = average(etudiant['quiz'])
tests = average(etudiant['tests'])
note = 0.1 * devoirs + 0.3 * quiz + 0.6 * tests
return note

def ecrire_lettre_note(note):
if note >= 90:
return "A"
elif note >= 80:
return "B"
elif note >= 70:
return "C"
elif note >= 60:
return "D"
else:
return "F"

etudiants = [lloyd, alice, tyler]

def calcul_classe_moyenne(etudiants):
resultats = []
for etudiant in etudiants:
resultats.append(calcul_classe_moyenne(etudiant))
return moyenne(resultats)
classe_moy = calcule_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

#4

`somme` is already a float, so this line is not needed.

`taille` can remain an integer since it is a counting number, not a real float.

This line should have no indentation.

#5

After having test what you offered me the console gives me this answer ...

None

One of the following variables is missing or damaged when you try to use it: alice, lloyd, tyler, students, calcule_classe_moyenne, ecrire_lettre_note

#6

I was only scanning the code, but will now proceed with a test. Check my earlier (edited) post. When that line is taken out of the block the code runs into an interpreter error:

NameError: global name 'average' is not defined

#7

These are the lines causing the error:

``````    devoirs = average(etudiant['devoirs'])
quiz = average(etudiant['quiz'])
tests = average(etudiant['tests'])``````

Change `average` to `moyenne`.

That solves it.

#8

this is not resolved ... even with the change it does not work ...
I have the same answer ...

#9

Please re-post your edited code. I made your code pass with only the two main changes mentioned above. (I left the float stuff alone, but it does work, so why have code you don't need?)

#10
``````lloyd = {
"noms": "Lloyd",
"devoirs": [90.0, 97.0, 75.0, 92.0],
"quiz": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"noms": "Alice",
"devoirs": [100.0, 92.0, 98.0, 100.0],
"quiz": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"noms": "Tyler",
"devoirs": [0.0, 87.0, 75.0, 22.0],
"quiz": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

def moyenne(nombres):
somme = sum(nombres)
taille = len(nombres)
taille = float(taille)
total = somme/taille

def calcule_moyenne(etudiant):
devoirs = moyenne(etudiant['devoirs'])
quiz = moyenne(etudiant['quiz'])
tests = moyenne(etudiant['tests'])
note = 0.1 * devoirs + 0.3 * quiz + 0.6 * tests
return note

def ecrire_lettre_note(note):
if note >= 90:
return "A"
elif note >= 80:
return "B"
elif note >= 70:
return "C"
elif note >= 60:
return "D"
else:
return "F"

etudiants = [lloyd, alice, tyler]

def calcul_classe_moyenne(etudiants):
resultats = []
for etudiant in etudiants:
resultats.append(calcul_classe_moyenne(etudiant))
return moyenne(resultats)

classe_moy = calcul_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

#11

That line can go. Dividing a float by an integer yields a float.

``````    classe_moy = calcul_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

should be outside of the block,

``````classe_moy = calcul_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

#12
``````classe_moy = calcul_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

is outside the block

I delete the line: taille = float(taille) ??

#13

You may, yes. It is unnecessary (but not causing a problem).

Be sure that the last three lines are not indented.

#14
``````Traceback (most recent call last):
File "python", line 53, in <module>
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne
File "python", line 51, in calcul_classe_moyenne``````

...

The long error message is back ...

#15

This is a recursion that has no base case (so no way to stop). Is this what you meant to do?

``````def calcule_classe_moyenne(etudiants):
resultats = []
for etudiant in etudiants:
resultats.append(calcule_moyenne(etudiant))
return moyenne(resultats)

classe_moy = calcule_classe_moyenne(etudiants)
print classe_moy
print ecrire_lettre_note(classe_moy)``````

#16

thanks it's ok ... I managed

#18