Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a tool permission boundary that restricts access to only approved tools.
Agentic AI
tool_permissions = [1](['search', 'calculator'])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list instead of a set can cause slower permission checks.
Using a dict or tuple is not suitable for membership testing in this context.
✗ Incorrect
We use a set to define tool permissions because it allows fast membership checks and ensures unique tools.
2fill in blank
mediumComplete the code to check if the tool 'email' is allowed by the permission boundary.
Agentic AI
if 'email' [1] tool_permissions: print('Access granted') else: print('Access denied')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' or '!=' compares values incorrectly here.
Using 'not in' reverses the logic and denies access when it should grant.
✗ Incorrect
The 'in' keyword checks if 'email' is a member of the tool_permissions set.
3fill in blank
hardFix the error in the code that attempts to add a new tool 'calendar' to the permission boundary.
Agentic AI
tool_permissions.[1]('calendar')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'append' causes an AttributeError because sets do not have this method.
Using 'insert' or 'extend' are list methods and not valid for sets.
✗ Incorrect
Sets use the 'add' method to include new elements, unlike lists which use 'append'.
4fill in blank
hardFill both blanks to create a function that returns True if a tool is allowed, False otherwise.
Agentic AI
def is_tool_allowed(tool): return tool [1] tool_permissions [2] True
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is' instead of '==' can cause unexpected behavior.
Using '!=' reverses the logic and returns incorrect results.
✗ Incorrect
The function checks if the tool is in the permissions set and compares the result to True for clarity.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps each tool to a boolean indicating permission.
Agentic AI
tool_access = {tool: tool [1] tool_permissions [2] True for tool in tools if tool [3] tool_permissions} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not in' in the filter excludes allowed tools incorrectly.
Using '!=' reverses the logic and causes wrong mappings.
✗ Incorrect
The comprehension checks membership with 'in', compares to True, and filters tools that are in permissions.
