0
0
DynamoDBquery~10 mins

DeleteItem in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to delete an item from the DynamoDB table named 'Users' using the primary key 'UserId'.

DynamoDB
response = table.delete_item(Key={'UserId': [1])
Drag options to blanks, or click blank then click option'
AUserId
B'123'
C'UserId'
D123
Attempts:
3 left
💡 Hint
Common Mistakes
Using the key name instead of the key value.
Omitting quotes around string key values.
2fill in blank
medium

Complete the code to delete an item from the 'Products' table where the primary key 'ProductId' equals 456.

DynamoDB
response = dynamodb.Table('Products').delete_item(Key=[1])
Drag options to blanks, or click blank then click option'
A{'ProductId': 456}
B{'ProductId': '456'}
C{'Id': 456}
D{'ProductId': 'ProductId'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using string quotes around numeric key values.
Using wrong attribute names in the key dictionary.
3fill in blank
hard

Fix the error in the code to delete an item from the 'Orders' table with 'OrderId' 789.

DynamoDB
response = table.delete_item(Key=[1])
Drag options to blanks, or click blank then click option'
A{'OrderId': 789}
B{'OrderId': '789'}
C{OrderId: 789}
D{'orderid': 789}
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted attribute names causing syntax errors.
Using wrong case for attribute names.
Using string instead of integer for numeric keys.
4fill in blank
hard

Fill both blanks to delete an item from the 'Employees' table where 'EmployeeId' is 101 and return all old attributes.

DynamoDB
response = table.delete_item(Key=[1], ReturnValues=[2])
Drag options to blanks, or click blank then click option'
A{'EmployeeId': 101}
BALL_OLD
C'ALL_OLD'
DNONE
Attempts:
3 left
💡 Hint
Common Mistakes
Passing ReturnValues without quotes causing errors.
Using wrong key dictionary format.
5fill in blank
hard

Fill all three blanks to delete an item from the 'Books' table with 'ISBN' '978-3-16-148410-0', conditionally only if 'InStock' is true, and return the old attributes.

DynamoDB
response = table.delete_item(Key=[1], ConditionExpression=[2], ReturnValues=[3])
Drag options to blanks, or click blank then click option'
A{'ISBN': '978-3-16-148410-0'}
BAttr('InStock').eq(True)
C'ALL_OLD'
DAttr('InStock') == True
Attempts:
3 left
💡 Hint
Common Mistakes
Using Python equality operator instead of Attr.eq() in ConditionExpression.
Passing ReturnValues without quotes.
Incorrect key dictionary format.