Lesson 1 of 5 · 2 min
Without evals every change is a guess
Write real questions with the answers you expect and run them after every change. Read the failures by hand before automating the grading.
cases = [("2+2", "4"), ("capital of France", "Paris"), ("largest planet", "Jupiter")]
def app(question):
return {"2+2": "4", "capital of France": "Paris is the capital.", "largest planet": "Saturn"}[question]
passed = 0
for q, expected in cases:
got = app(q)
ok = expected.lower() in got.lower()
passed += ok
print("pass" if ok else "FAIL", "|", q, "->", got)
print(f"{passed}/{len(cases)}")
