0
0
DSA Pythonprogramming~10 mins

Array Deletion at Middle Index 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 remove the middle element from the list.

DSA Python
arr = [1, 2, 3, 4, 5]
mid = len(arr) // 2
arr.[1](mid)
print(arr)
Drag options to blanks, or click blank then click option'
Ainsert
Bremove
Cappend
Dpop
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove() which removes by value, not index.
Using append() or insert() which add elements instead of removing.
2fill in blank
medium

Complete the code to find the middle index of the list correctly.

DSA Python
arr = [10, 20, 30, 40, 50, 60]
mid = [1]
print(mid)
Drag options to blanks, or click blank then click option'
Alen(arr) / 2
Blen(arr) // 2
Clen(arr) - 1
Dlen(arr) + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using / which returns a float, causing errors when used as index.
Using len(arr) - 1 which gives last index, not middle.
3fill in blank
hard

Fix the error in the code to delete the middle element from the list.

DSA Python
arr = [7, 8, 9, 10, 11]
mid = len(arr) // 2
arr.[1](mid)
print(arr)
Drag options to blanks, or click blank then click option'
Ainsert
Bremove
Cpop
Dappend
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove() with an index value instead of the element value.
Using append() or insert() which add elements instead of removing.
4fill in blank
hard

Fill both blanks to create a new list without the middle element.

DSA Python
arr = [2, 4, 6, 8, 10]
mid = len(arr) // 2
new_arr = [arr[[1]] for [2] in range(len(arr)) if [2] != mid]
print(new_arr)
Drag options to blanks, or click blank then click option'
Ai
Bj
Cx
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causing NameError.
Using the middle index inside the list comprehension causing wrong output.
5fill in blank
hard

Fill all three blanks to delete the middle element and print the updated list.

DSA Python
arr = [3, 5, 7, 9, 11, 13]
mid = len(arr) // 2
arr.[1](mid)
print(arr[[2]:[3]])
Drag options to blanks, or click blank then click option'
Apop
B0
Cmid
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove() instead of pop() causing errors.
Incorrect slice indices causing wrong output.