Hint: Use LastEvaluatedKey as ExclusiveStartKey to continue scan [OK]
Common Mistakes:
Using Limit as ExclusiveStartKey
Confusing scan with query parameters
Using invalid parameter names
3. Given the following scan code snippet, what will be the output if the table has 15 items and Limit is set to 5?
response = table.scan(Limit=5)
items = response['Items']
last_key = response.get('LastEvaluatedKey')
print(len(items), last_key is not None)
medium
A. 5 False
B. 15 False
C. 5 True
D. 15 True
Solution
Step 1: Understand Limit Effect on Scan
Setting Limit=5 returns up to 5 items in one scan call, not all 15.
Step 2: Check LastEvaluatedKey Presence
Since there are more items after 5, LastEvaluatedKey will be present (not None), indicating more data.
Final Answer:
5 True -> Option C
Quick Check:
Limit=5 returns 5 items and LastEvaluatedKey exists [OK]
Hint: Limit controls items returned; LastEvaluatedKey shows more data [OK]
Common Mistakes:
Assuming all items return ignoring Limit
Expecting LastEvaluatedKey to be None always
Confusing item count with total table size
4. You wrote this code to paginate a scan but it returns only the first page repeatedly:
response = table.scan(Limit=3)
items = response['Items']
while 'LastEvaluatedKey' in response:
response = table.scan(Limit=3)
items.extend(response['Items'])
print(len(items))
What is the error?
medium
A. Missing ExclusiveStartKey in the subsequent scan calls
B. Limit should be increased to get all items
C. Items list should be reset inside the loop
D. LastEvaluatedKey should be deleted after each scan
Solution
Step 1: Analyze Pagination Loop
The loop calls scan repeatedly but does not pass ExclusiveStartKey, so it always scans from start.
Step 2: Identify Missing Parameter
To continue scanning, ExclusiveStartKey must be set to previous LastEvaluatedKey in each call.
Final Answer:
Missing ExclusiveStartKey in the subsequent scan calls -> Option A
Quick Check:
Pagination needs ExclusiveStartKey to continue [OK]
Hint: Pass ExclusiveStartKey to continue scan pages [OK]
Common Mistakes:
Not passing ExclusiveStartKey in loop
Increasing Limit instead of fixing pagination
Resetting items list inside loop
5. You want to scan a DynamoDB table with 1000 items but only want to process 100 items at a time to avoid timeouts. Which approach correctly implements scan pagination to achieve this?
hard
A. Set ExclusiveStartKey to null and scan with Limit=100 once
B. Use a loop with Limit=100 and pass ExclusiveStartKey from LastEvaluatedKey until no more keys
C. Use ScanIndexForward=true with Limit=100 to paginate
D. Scan once with Limit=1000 and split results in code
Solution
Step 1: Understand Pagination Requirements
To process 100 items at a time, scan must be done in chunks with Limit=100 and continue using ExclusiveStartKey.
Step 2: Evaluate Options
Use a loop with Limit=100 and pass ExclusiveStartKey from LastEvaluatedKey until no more keys correctly loops with Limit=100 and uses ExclusiveStartKey from LastEvaluatedKey. Scan once with Limit=1000 and split results in code fetches all at once, risking timeout. Use ScanIndexForward=true with Limit=100 to paginate uses wrong parameter for scan. Set ExclusiveStartKey to null and scan with Limit=100 once scans only once without continuation.
Final Answer:
Use a loop with Limit=100 and pass ExclusiveStartKey from LastEvaluatedKey until no more keys -> Option B
Quick Check:
Paginate with Limit and ExclusiveStartKey loop [OK]
Hint: Loop with Limit and ExclusiveStartKey until no LastEvaluatedKey [OK]
Common Mistakes:
Fetching all items at once risking timeout
Using query parameters for scan
Not looping to continue scan
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.