0
0
Agentic_aiml~10 mins

Rate limiting and budget controls in Agentic Ai - Interactive Code Practice

Choose your learning style8 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
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
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
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
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