بتل کد Battle Codeدارد باز می‌شود…

Track A: A Fair Test Set for the Bot چالش 3 از جلسه‌ی 77، متوسط

مسیر الف. قبل از ساختن ربات، آزمونش را بنویس و بررسی کن منصفانه است. تابع audit(tests, notes) را بنویس که مشکل‌ها را به این ترتیب چاپ کند: ۱) هر سؤال تکراری: duplicate: <question>؛ ۲) هر کلمه‌ی کلیدی که در جزوه (با حروف کوچک) نیست: not in notes: <keyword> (آزمون ناعادلانه است)؛ ۳) اگر سؤال بی‌جواب (None) کمتر از ۲ تاست: need at least 2 unanswerable (have <n>). اگر مشکلی نبود test set OK. خروجی:
duplicate: What is evaporation?
not in notes: photosynth
need at least 2 unanswerable (have 1)

NOTES = '''Evaporation is when the sun heats water and it turns into vapour.
Condensation is when vapour cools and forms clouds.
Precipitation is rain or snow falling from heavy clouds.
Transpiration is when plants lose water through their leaves.'''

TESTS = [   # (question, key word, or None when the notes have no answer)
    ("What is evaporation?", "vapour"),
    ("What is condensation?", "clouds"),
    ("What is evaporation?", "evaporation"),
    ("How do plants lose water?", "leaves"),
    ("What do plants make with light?", "photosynth"),
    ("Who was the first head teacher of our school?", None),
]


def audit(tests, notes):
    print("test set OK")


audit(TESTS, NOTES)

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 77: پروژه‌ی آزاد با مربی (۱): نقشه · چالش بعدی: Track B: Balance and a Test Set

بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال