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
- Make
define(word)that returnsrobot: a machine that does jobs by itselffor words inWORDS, andI don't know that word.for others. - Make
helper(question)that picks from all four tools withpip.ask_with_toolsand returns the answer as text. - When no tool fits,
helperreturns Pip's reply. - Print
helper(q)for each of the 5HOMEWORKquestions.
💡 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.