0
0
DynamoDBquery~10 mins

Limit and pagination 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 limit the number of items returned to 5.

DynamoDB
response = table.scan(Limit=[1])
Drag options to blanks, or click blank then click option'
A0
B10
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number larger than needed.
Setting Limit to 0 which returns no items.
2fill in blank
medium

Complete the code to start scanning from the last evaluated key stored in last_key.

DynamoDB
response = table.scan(ExclusiveStartKey=[1])
Drag options to blanks, or click blank then click option'
Alast_key
B{}
CNone
Dstart_key
Attempts:
3 left
💡 Hint
Common Mistakes
Passing None which means start from the beginning.
Using a wrong variable name.
3fill in blank
hard

Fix the error in the code to correctly check if there are more items to scan.

DynamoDB
if 'LastEvaluatedKey' in response and response[1] 'LastEvaluatedKey' is not None:
    last_key = response['LastEvaluatedKey']
Drag options to blanks, or click blank then click option'
Ais
B==
Cnot in
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using == which checks equality, not inequality.
Using is which is not correct for this check.
4fill in blank
hard

Fill both blanks to scan with a limit of 10 and start from the last evaluated key.

DynamoDB
response = table.scan(Limit=[1], ExclusiveStartKey=[2])
Drag options to blanks, or click blank then click option'
A10
Blast_key
C5
D{}
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong limit values.
Not passing the correct start key variable.
5fill in blank
hard

Fill all three blanks to create a loop that paginates through all items with a limit of 3.

DynamoDB
last_key = None
items = []
while True:
    response = table.scan(Limit=[1], ExclusiveStartKey=[2])
    items.extend(response['Items'])
    if 'LastEvaluatedKey' not in response or response['LastEvaluatedKey'] is None:
        break
    last_key = response[[3]]
Drag options to blanks, or click blank then click option'
A3
Blast_key
C'LastEvaluatedKey'
D'Items'
Attempts:
3 left
💡 Hint
Common Mistakes
Not updating last_key correctly.
Using wrong keys or limit values.