Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new item in a DynamoDB table.
DynamoDB
response = table.[1](Item={'UserId': '123', 'Name': 'Alice'})
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using get_item instead of put_item
Using update_item without an existing item
✗ Incorrect
The put_item method adds a new item to the table.
2fill in blank
mediumComplete the code to read an item from a DynamoDB table by its key.
DynamoDB
response = table.[1](Key={'UserId': '123'})
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using put_item to read data
Using delete_item instead of get_item
✗ Incorrect
The get_item method retrieves an item by its key.
3fill in blank
hardFix the error in the code to update an existing item in DynamoDB.
DynamoDB
response = table.[1](Key={'UserId': '123'}, UpdateExpression='SET Age = :age', ExpressionAttributeValues={':age': 30})
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using put_item which replaces the whole item
Using get_item which only reads data
✗ Incorrect
The update_item method updates attributes of an existing item.
4fill in blank
hardFill both blanks to delete an item by key and confirm the operation.
DynamoDB
response = table.[1](Key=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using put_item instead of delete_item
Providing wrong key structure
✗ Incorrect
delete_item removes the item with the specified key from the table.
5fill in blank
hardFill all three blanks to create an item and then read it back.
DynamoDB
table.[1](Item={'UserId': '456', 'Name': 'Bob'}) response = table.[2](Key=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up method names
Using wrong key format
✗ Incorrect
This sequence creates an item, reads it back, and the key is used to identify the item.