Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the token counter variable.
Agentic AI
token_count = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing token_count to None or an empty string instead of zero.
✗ Incorrect
We start counting tokens from zero, so initializing token_count to 0 is correct.
2fill in blank
mediumComplete the code to add the number of tokens used in the current step to the total count.
Agentic AI
token_count [1]= tokens_used Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
✗ Incorrect
We add the tokens used in the current step to the total token_count using '+='.
3fill in blank
hardFix the error in the code to calculate the cost based on tokens used and price per token.
Agentic AI
cost = tokens_used [1] price_per_token Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or division instead of multiplication.
✗ Incorrect
Cost is calculated by multiplying tokens used by price per token, so '*' is correct.
4fill in blank
hardFill both blanks to create a dictionary that tracks tokens and cost for each step.
Agentic AI
usage = {'tokens': [1], 'cost': [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing total_cost with cost for the current step.
✗ Incorrect
The 'tokens' key should hold tokens_used, and 'cost' should hold the calculated cost.
5fill in blank
hardFill all three blanks to update total tokens, calculate cost, and store usage info.
Agentic AI
token_count [1]= tokens_used cost = tokens_used [2] price_per_token usage = {'tokens': tokens_used, 'cost': [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators or storing wrong values in usage.
✗ Incorrect
We add tokens_used to token_count, multiply tokens_used by price_per_token for cost, and store cost in usage.
