جواب «Step 1: Look Up the Notes» چالش 1 از جلسهی 70
سؤال
تابع lookup(topic) را بنویس: موضوع را با strip() و lower() یکسان کن؛ اگر در NOTES بود متنش را برگردان، وگرنه not found: <topic> (با موضوعِ یکسانشده). خروجی:Plants turn light, water and CO2 into sugar and oxygen.Gravity pulls masses toward each other.not found: volcanoes
راهنما
key = topic.strip().lower()؛ if key in NOTES: return NOTES[key]؛ وگرنه return "not found: " + key.
یک جواب درست
NOTES = {
"photosynthesis": "Plants turn light, water and CO2 into sugar and oxygen.",
"gravity": "Gravity pulls masses toward each other.",
"cell": "The cell is the smallest unit of life.",
}
def lookup(topic):
key = topic.strip().lower()
if key in NOTES:
return NOTES[key]
return "not found: " + key
print(lookup("Photosynthesis"))
print(lookup(" gravity "))
print(lookup("Volcanoes"))
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن