9
QuizMultiple Choice

Use Data Structures — Unit test

Question 9 • Introduction to Information Technology - EL3701

Which line of code will eliminate the element “calculator” from an array of supplies?

Answer
A
supplies.append(“calculator”)
B
supplies.pop(“calculator”)
C
supplies.delete(“calculator”)
D
supplies.remove(“calculator”)

Explanation

Use the array’s remove method to delete an element by its value: supplies.remove("calculator"). The append method adds an element, while pop typically removes an element by its index rather than by its value. The delete method shown is not the standard array method for removing a specified value.

AI-written and checked against the verified answer.

Previous
Next