Complete the code to perform a Query operation on a DynamoDB table.
response = table.[1](KeyConditionExpression=Key('UserId').eq('123'))
The query method retrieves items based on primary key values, making it efficient.
Complete the code to perform a Scan operation on a DynamoDB table.
response = table.[1]()The scan method reads every item in the table, which can be slow for large tables.
Fix the error in the code to improve performance by using the correct method.
response = table.[1](KeyConditionExpression=Key('Status').eq('Active'))
Using query with a key condition is more efficient than scanning with a filter.
Fill both blanks to create a dictionary comprehension that shows item counts for active users using Query.
active_users = {item['UserId']: item['Count'] for item in table.[1](KeyConditionExpression=Key('Status').eq('Active')).[2]Use query to get items with key condition, then access Items to iterate results.
Fill all three blanks to create a dictionary comprehension that filters items with Query and a condition.
filtered = {item['Id']: item['Value'] for item in table.[1](KeyConditionExpression=Key('Category').eq('Books')).[2] if item['Value'] [3] 100}Use query to filter by key, access Items to get results, and filter values greater than 100.