0
0
DynamoDBquery~10 mins

Scan with filter expressions 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 scan the DynamoDB table with a filter expression to get items where the attribute 'Status' equals 'Active'.

DynamoDB
response = table.scan(FilterExpression=Attr('Status')[1]'Active')
Drag options to blanks, or click blank then click option'
A==
B!=
C.eq
D.eq(
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' directly inside FilterExpression causes syntax errors.
Forgetting to use Attr() for attribute references.
2fill in blank
medium

Complete the code to scan the table and filter items where the 'Age' attribute is greater than 30.

DynamoDB
response = table.scan(FilterExpression=Attr('Age')[1]30)
Drag options to blanks, or click blank then click option'
A.gt(
B.lt(
C==
D.eq(
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' directly instead of the method.
Using lt which means less than.
3fill in blank
hard

Fix the error in the filter expression to scan items where 'Category' is not equal to 'Electronics'.

DynamoDB
response = table.scan(FilterExpression=Attr('Category')[1]'Electronics')
Drag options to blanks, or click blank then click option'
A!=
B.ne(
C.neq(
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' directly causes syntax errors.
Using a non-existent method like neq.
4fill in blank
hard

Fill both blanks to scan items where 'Price' is less than 100 and 'InStock' is true.

DynamoDB
response = table.scan(FilterExpression=Attr('Price')[1]100) & Attr('InStock')[2]True)
Drag options to blanks, or click blank then click option'
A.lt(
B.eq(
C.gt(
D.ne(
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of < for price.
Using != instead of == for boolean.
5fill in blank
hard

Fill all three blanks to scan items where the 'Rating' is greater than or equal to 4, 'Category' equals 'Books', and 'Available' is true.

DynamoDB
response = table.scan(FilterExpression=(Attr('Rating')[1]4) & (Attr('Category')[2]'Books') & (Attr('Available')[3]True))
Drag options to blanks, or click blank then click option'
A.gte(
B.eq(
D.gt(
Attempts:
3 left
💡 Hint
Common Mistakes
Using .gt instead of .gte for greater or equal.
Using != instead of eq for equality.