Bird
Raised Fist0
Agentic AIml~10 mins

Token usage and cost tracking in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the token counter variable.

Agentic AI
token_count = [1]
Drag options to blanks, or click blank then click option'
A0
BNone
C1
D''
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing token_count to None or an empty string instead of zero.
2fill in blank
medium

Complete 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'
A+
B*
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
3fill in blank
hard

Fix 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'
A+
B-
C/
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or division instead of multiplication.
4fill in blank
hard

Fill 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'
Atokens_used
Btotal_cost
Ccost
Dtoken_count
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing total_cost with cost for the current step.
5fill in blank
hard

Fill 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'
A+
B*
Ccost
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators or storing wrong values in usage.