Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
2fill in blank
mediumComplete 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'
Attempts:
3 left
3fill in blank
hardFix 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'
Attempts:
3 left
4fill in blank
hardFill 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'
Attempts:
3 left
5fill in blank
hardFill 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'
Attempts:
3 left
