Bird
Raised Fist0
Agentic AIml~10 mins

Rate limiting and budget controls 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 set a maximum number of API calls per minute.

Agentic AI
max_calls_per_minute = [1]
Drag options to blanks, or click blank then click option'
A100
Bapi_limit
CNone
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the limit to None or negative values which disables or breaks the limit.
2fill in blank
medium

Complete the code to check if the current usage exceeds the budget.

Agentic AI
if current_usage [1] budget_limit:
    print('Budget exceeded')
Drag options to blanks, or click blank then click option'
A<
B<=
C==
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= or < which would not catch exceeding usage.
3fill in blank
hard

Fix the error in the code that resets the usage counter after a time window.

Agentic AI
if time.time() - last_reset_time [1] reset_interval:
    usage_count = 0
    last_reset_time = time.time()
Drag options to blanks, or click blank then click option'
A==
B<=
C>=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or <= which resets too early or not at the right time.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that tracks usage per user only if usage is below the limit.

Agentic AI
usage_per_user = {user: usage[1] for user, usage in user_usage.items() if usage [2] limit}
Drag options to blanks, or click blank then click option'
A+
B<
C<=
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition or wrong comparison operators.
5fill in blank
hard

Fill all three blanks to create a rate limiter function that returns True if under limit and updates usage.

Agentic AI
def rate_limiter(user):
    if usage.get(user, 0) [1] limit:
        usage[user] = usage.get(user, 0) [2] 1
        return [3]
    return False
Drag options to blanks, or click blank then click option'
A<
B+
CTrue
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of < for comparison, or returning False incorrectly.