# 9/9: How is Everybody Doing?

#1

``````Hi. This is my code :

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]
}

# Ajoutez votre fonction ci-dessous !
def moyenne(nombres):
total = sum(nombres)
total = float(total)
total /= len(nombres)

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

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"
print ecrire_lettre_note(calcule_moyenne(lloyd))

def calcul_classe_moyenne(etudiants):
resultats = []
for etudiant in classe:
resultats.append(calcule_moyenne(etudiant))
return moyenne(resultats)
etudiants = [lloyd, alice, tyler]
print calcul_classe_moyenne(etudiants)
print ecrire_lettre_note(calcul_classe_moyenne(etudiants))

**Error message :**

**Oups, merci de rĂ©essayer. Une des variables suivantes est manquante ou endommagĂ©e quand on essaye de l'utiliser : alice, lloyd, tyler, etudiants, calcule_classe_moyenne, ecrire_lettre_note**

I don't see my mistake.``````

#2

Have you tried printing those names? If it's not there then it can't be printed and you'll get an error message saying what isn't there. Don't even need to print them, just reference them so that if they are missing there's an exception.

#3

Hi Ionatan

B
Traceback (most recent call last):
** File "python", line 53, in **
** File "python", line 48, in calcul_classe_moyenne**
NameError: global name 'classe' is not defined

This is the message in the console.

#4

I don't think `classe` was one of the names that were mentioned, why are you referencing that? Or are you referencing something else and it isn't showing up in your post? Take care to keep stuff like that intact.

If it's saying one of the mentioned names is missing, then you've got your answer right there.

#5

This is the end of the code :

def calcul_classe_moyenne(etudiants):
resultats = []
for etudiant in classe:
resultats.append(calcule_moyenne(etudiant))
return moyenne(resultats)
etudiants = [lloyd, alice, tyler]
print calcul_classe_moyenne(etudiants)
print ecrire_lettre_note(calcule_classe_moyenne(etudiants))

It seems to be correct.