Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to batch write multiple items in DynamoDB.
DynamoDB
response = table.[1](RequestItems=batch_items) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using put_item writes only one item at a time.
get_item is for reading, not writing.
delete_item removes items, not writes.
✗ Incorrect
The batch_write_item method allows writing multiple items in one request, improving efficiency.
2fill in blank
mediumComplete the code to prepare a batch of items for writing.
DynamoDB
batch_items = {table_name: [[1]]} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetRequest is for reading, not writing.
DeleteRequest removes items, not adds.
UpdateRequest is not valid in batch write.
✗ Incorrect
Batch write requires PutRequest with the item to add.
3fill in blank
hardFix the error in the batch write code by choosing the correct parameter name.
DynamoDB
response = client.batch_write_item([1]=batch_items) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Items' causes a parameter error.
BatchItems and WriteItems are not valid parameter names.
✗ Incorrect
The correct parameter name is RequestItems for batch_write_item.
4fill in blank
hardFill both blanks to create a batch get request for multiple keys.
DynamoDB
response = client.batch_get_item(RequestItems=[1]: [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'batch_items' instead of table name.
Using 'Item' instead of direct key dicts in the list.
✗ Incorrect
Batch get requires the table name as key and a dict with "Keys" containing list of key dictionaries.
5fill in blank
hardFill all three blanks to filter batch get results by attribute existence.
DynamoDB
filtered = [item for item in response['Responses'][[1]] if [2] in item and item[[3]] == True]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'attribute_exists' as a key in item is incorrect.
Confusing 'Key' with 'attribute_exists' or 'isActive'.
✗ Incorrect
We access items by table name, check for 'isActive' existence, and filter where 'isActive' is True.