0%
⭐ 0 XPMap
Chapter 3 · Checkpoint · 40 XP

Homework Helper

🏆 Checkpoint! Time to put your toolbelt to work. Your friend has five homework questions: a sum, the weather for a geography project, a dice roll for a game, and two words they don't know.

You'll add one new tool, define(word), that looks words up in a dictionary. Pip already knows to pick a tool named define when a question asks what a word means:

{"tool": "define", "args": {"word": "robot"}}

Then build helper(question), which always returns text so your friend gets a tidy answer every time. str() turns a number into text: str(19) is "19". The checker also asks your helper questions you haven't seen.

Instructions

  1. Make define(word) that returns robot: a machine that does jobs by itself for words in WORDS, and I don't know that word. for others.
  2. Make helper(question) that picks from all four tools with pip.ask_with_tools and returns the answer as text.
  3. When no tool fits, helper returns Pip's reply.
  4. Print helper(q) for each of the 5 HOMEWORK questions.
💡 Hint

tools = {"calc": calc, "weather": weather, "roll": roll, "define": define}. In helper, wrap the tool's answer in str(), but return Pip's reply as it is.

Ask the community

bot.py
Terminal
← BackNext →

Chapter 3: Tools

The full quest map

Talk it out

  1. Read the instruction with the ✗ out loud.
  2. Say what your code does, line by line, as if to a friend.
  3. Find the line where what it does and what you want split apart.
  4. Press Run and read the terminal. Is that what you expected?
  5. Still stuck? Press Ask Pip why, or peek at the solution.
  6. Or ask on the community help board: say which quest, and paste your code.
New badge!

Your bot just got a new part. See it on the quest map.

Name your bot

It levels up as you play, and gets a new part with every chapter.