Complete the code to put an item into a DynamoDB table.
response = table.put_item(Item={'UserId': '123', 'Name': [1])The put_item method requires the item attributes as key-value pairs. Here, the 'Name' attribute should have a string value like 'Alice'.
Complete the code to get an item by its primary key from the DynamoDB table.
response = table.get_item(Key={'UserId': [1])The primary key value must be a string matching the key type. Here, 'UserId' is a string key, so use quotes around '123'.
Fix the error in the code to update an attribute in a DynamoDB item.
response = table.update_item(Key={'UserId': '123'}, UpdateExpression='SET [1] = :val', ExpressionAttributeValues={':val': 'Bob'})In the UpdateExpression, attribute names should not be quoted. Use the attribute name directly like Name.
Fill both blanks to query items where 'Age' is greater than 25.
response = table.query(KeyConditionExpression=[1].eq('123'), FilterExpression=[2].gt(25))
Use Key('UserId') for the partition key equality condition and Attr('Age') for the filter condition with greater than.
Fill all three blanks to create a dictionary of item names and their prices for items priced above 100.
result = {item['[1]']: item['[2]'] for item in items if item['[3]'] > 100}The dictionary keys are item names, values are prices, and the filter checks if price is greater than 100.