Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an element to the end of the queue.
DSA Python
queue = [1, 2, 3] queue.[1](4) print(queue)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop removes an element instead of adding.
Using insert requires an index and adds at that position.
✗ Incorrect
The append method adds an element to the end of the list, which simulates enqueue in a queue.
2fill in blank
mediumComplete the code to enqueue the value 10 into the queue.
DSA Python
queue = [] value = 10 queue.[1](value) print(queue)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop or remove which remove elements.
Using insert without specifying index.
✗ Incorrect
To add a value to the end of the queue, use append.
3fill in blank
hardFix the error in the enqueue operation to add 5 to the queue.
DSA Python
queue = [1, 2, 3] queue.[1](5) print(queue)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop or remove instead of append.
Using insert without index.
✗ Incorrect
The correct method to add an element at the end is append. Using pop or remove removes elements instead.
4fill in blank
hardFill both blanks to enqueue the value 7 into the queue and then print it.
DSA Python
queue = [4, 5, 6] queue.[1]([2]) print(queue)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop or remove which remove elements.
Not providing the value to add.
✗ Incorrect
Use append to add the value 7 to the queue.
5fill in blank
hardFill both blanks to enqueue the uppercase string 'HELLO' into the queue and then print it.
DSA Python
queue = ['a', 'b', 'c'] value = 'hello' queue.[1](value[2]) print(queue)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop instead of append.
Forgetting to convert to uppercase.
Adding extra characters in print.
✗ Incorrect
Use append to add the value. Convert value to uppercase with .upper(). Print the queue as is.