Unit 5 / Une journée au supermarché / Faire un achat


#1

courses = ["banane", "orange", "pomme"]

stock = { "banane": 6,
    "pomme": 0,
    "orange": 32,
    "poire": 15
}
    
prix = { "banane": 4,
    "pomme": 2,
    "orange": 1.5,
    "poire": 3
}

# Ecrivez votre code ci-dessous :
def calculer_facture(nourriture):
    totale = 0
    for nourriture in courses :
        total += prix[nourriture]
    return total

pouvez vous me dire pourquoi c'est faux s'ii vous plait


#2

c bon g trouver ca donne

courses = ["banane", "orange", "pomme"]

stock = { "banane": 6,
    "pomme": 0,
    "orange": 32,
    "poire": 15
}
    
prix = { "banane": 4,
    "pomme": 2,
    "orange": 1.5,
    "poire": 3
}

# Ecrivez votre code ci-dessous :
def calculer_facture(nourriture):
    totale = 0
    for nourriture in courses :
        totale += prix["nourriture"]
    return totale

#3

Variable totale doit correspondre: total

La nourriture est la liste dont nous avons besoin pour itérer:

def calculer_facture(nourriture):
    total = 0
    for item in nourriture:
        total += prix[item]
    return total

https://www.codecademy.com/fr/courses/python-beginner-fr-FR-4az90/2/2


#4

ok merci:grin::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile: