0
0
DSA Pythonprogramming~10 mins

Traversal Forward and Backward in DSA Python - Interactive Practice

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

Complete the code to print all elements of the list forward.

DSA Python
for i in range(len(lst)):
    print(lst[[1]])
Drag options to blanks, or click blank then click option'
Alen(lst)
Bi
C0
Dlst[i]
Attempts:
3 left
💡 Hint
Common Mistakes
Using the list itself as an index like lst[lst[i]]
Using a fixed index like 0 instead of the loop variable
2fill in blank
medium

Complete the code to print all elements of the list backward.

DSA Python
for i in range(len(lst)-1, [1], -1):
    print(lst[i])
Drag options to blanks, or click blank then click option'
A1
Blen(lst)
C-1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as stop index which excludes index 0
Using len(lst) which is out of range
3fill in blank
hard

Fix the error in the code to traverse the list forward and print elements.

DSA Python
i = 0
while i < [1]:
    print(lst[i])
    i += 1
Drag options to blanks, or click blank then click option'
Alen(lst)
Blst
Ci
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing 'i' with the list itself instead of its length
Using a fixed number instead of the list length
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

DSA Python
{word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length
Using '<' instead of '>' in the condition
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values for positive values only.

DSA Python
result = {{ [1]: [2] for k, v in data.items() if v [3] 0 }}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using original keys instead of uppercase
Using '<' instead of '>' in the condition
Using keys as values