0
0
Redisquery~10 mins

ZRANGE and ZREVRANGE for reading in Redis - Interactive Code Practice

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

Complete the code to get the first 3 elements from a sorted set named 'myzset'.

Redis
ZRANGE myzset 0 [1]
Drag options to blanks, or click blank then click option'
A2
B3
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as the end index returns 4 elements instead of 3.
Using negative indices without understanding their meaning.
2fill in blank
medium

Complete the code to get the last 2 elements from a sorted set named 'myzset' using ZREVRANGE.

Redis
ZREVRANGE myzset [1] -1
Drag options to blanks, or click blank then click option'
A0
B-2
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the start index returns elements from the beginning, not the end.
Using -1 as the start index returns only the last element.
3fill in blank
hard

Fix the error in the command to get elements from index 1 to 3 in 'myzset'.

Redis
ZRANGE myzset [1] 3
Drag options to blanks, or click blank then click option'
A1
B0
C2
D-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the start index returns elements from index 0, not 1.
Using negative indices incorrectly.
4fill in blank
hard

Fill both blanks to get elements from index 2 to 4 in reverse order from 'myzset'.

Redis
ZREVRANGE myzset [1] [2]
Drag options to blanks, or click blank then click option'
A4
B2
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping start and end indices incorrectly.
Using negative indices without understanding their effect.
5fill in blank
hard

Fill all three blanks to get elements from index 1 to 3 with scores included from 'myzset'.

Redis
ZRANGE myzset [1] [2] [3]
Drag options to blanks, or click blank then click option'
A0
B1
CWITHSCORES
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Placing WITHSCORES before indices.
Using incorrect indices that do not match the desired range.