Complete the code to perform a Scan operation on a DynamoDB table named 'Products'.
response = dynamodb_client.[1](TableName='Products')
The scan method reads every item in the table, which is useful when you need to retrieve all data without filtering by key.
Complete the code to add a filter expression to the Scan operation to only get items where 'Category' equals 'Books'.
response = dynamodb_client.scan(TableName='Products', FilterExpression='[1] = :cat', ExpressionAttributeValues={':cat': {'S': 'Books'}})
The attribute name must match exactly the DynamoDB attribute, which is 'Category' with uppercase 'C'.
Fix the error in the Scan operation that tries to filter items by 'Price' less than 20.
response = dynamodb_client.scan(TableName='Products', FilterExpression='Price [1] :val', ExpressionAttributeValues={':val': {'N': '20'}})
The correct operator for 'less than' in DynamoDB FilterExpression is '<'.
Fill both blanks to complete the Scan operation that retrieves items with 'Stock' greater than 0 and projects only 'ProductId' and 'Stock'.
response = dynamodb_client.scan(TableName='Products', FilterExpression='Stock [1] :min', ExpressionAttributeValues={':min': {'N': '0'}}, ProjectionExpression='[2], Stock')
The filter uses '>' to get items with Stock greater than 0, and the projection includes 'ProductId' and 'Stock'.
Fill all three blanks to complete the Scan operation that paginates results using 'LastEvaluatedKey', filters items with 'Status' equal to 'Active', and projects 'UserId' and 'Status'.
response = dynamodb_client.scan(TableName='Users', FilterExpression='Status = :stat', ExpressionAttributeValues={':stat': {'S': 'Active'}}, ProjectionExpression='[1], Status', ExclusiveStartKey=[2])
'UserId' is projected, 'last_key' is the variable holding the last evaluated key, and '{}' is used when there is no last key to start from.