Check your understanding of the previous reading: the Protein Lookup program.

Question 1

The Protein Lookup program uses a variety of loop patterns. Which pattern is relevant to which function?
load_foods
find_foods
get_food
total_protein
search
add_food

Question 2

Which of these is NOT an accurate description of which route leads to the next route?

Select one answer, then check.

  • Accurate. index's page has Button("Search", "search").
  • This is the odd one out, but not because the button is missing: no_food_found_page does return a page with Button("Back", "index"). The option itself is careful not to call it "the no_food_found_page route" (unlike every other option here), because it isn't one: it has no @route decorator, and is only ever reached from inside search. So it does not describe one route leading to the next, the way the question asks.
  • Accurate. A successful search builds one Button(food.name, "add_food", ...) per result.
  • Accurate. The results page also has a Button("Back", "index").
  • Accurate. add_food ends with return index(state).

Question 3

According to the tool, how much protein is in a Crumpet?

Show worked solution

The shipped food_simple.tsv has one row for Crumpet: category Crumpet, name Crumpet, id 52101040, protein 8.87. Searching "Crumpet" in the tool returns that row's protein value directly.