Skip to content
Programming Problems · Q7

Q.Write a program to read elements of a list and do the following.

a) The program should ask for the position of the element to be deleted from the list and delete the element at the desired position in the list.
b) The program should ask for the value of the element to be deleted from the list and delete this value from the list.
CBSENCERTSubjective· 3mImportance★★★★★est
90% · 27/30 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Concept understanding — List Operations

A shopping list on paper is more than the items written on it — it is the things you can do with it: read the third entry, cross one out, add another at the bottom, check whether "milk" is already there. A Python list is the program's version of that paper: an ordered collection that can hold many values under one name, written in square brackets. List operations are the standard actions the language gives you for working with the whole collection or any part of it.

marks = [78, 92, 65, 88, 71]

The core operations every student must command:

  • Indexing — fetch one element by its position: marks[0] is 78. Counting starts at zero, so the last of five items is marks[4]. Negative indexes count from the end: marks[-1] is the last element, no matter how long the list grows.
  • Slicing — fetch a sub-list: marks[1:4] gives the elements at positions 1, 2 and 3. The start is included, the stop is excluded. Leaving an end open means "to the edge": marks[:3] is the first three, marks[2:] is everything from position 2 onward.
  • Concatenation — joining two lists with the plus sign produces a new, longer list.
  • Repetition — a list times an integer produces repeated copies, just as with strings: [0] * 5 builds a list of five zeros, a handy way to prepare storage.
  • Membership — the in and not in tests answer yes or no: 92 in marks is True. No loop needed.
  • Traversal — a for loop visits every element in order, which is how totals, searches and printouts are written.
  • Length — len(marks) reports how many elements the list currently holds. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.