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
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):
return NOTES[topic]
print(lookup("Photosynthesis"))
print(lookup(" gravity "))
print(lookup("Volcanoes"))
راهنما و جواب این چالش · برگشت به درس جلسهی 70: پروژه: دستیار درس · چالش بعدی: Step 2: A Calculator Without eval
بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال