#python
#pythonprogramming
Python MCQ Questions and answers,
Python MCQ , Python Programming,
Python, Python Sequence, Python Iterable,
list mutable,
list method remove,
del statement
list item assignment using index, slice
Indexing list items to replace.
Indexing list items to append, insert, or replace.
list Indexing, slicing allows change in existing values using Assignment.
list[i] = x, Assigns item x at position i of list by replacing existing item.
list[i:j:k] = x, appends, inserts, or replaces item based on i,j,k
Non-empty slice Assignment of list→updates (replaces) the elements that the slice covers.
Item Assignment using
Index: lst[i]=itr
→replaces item at i by itr
→No change in list len
i not in range⇒IndexError
Slice: lst[i:j:k]=itr
→removes items in range
and inserts itr as individual item
→May change list len
With step k,
len slice ≠ len itr⇒ValueError
Mutable Sequence method: remove,
List method: pop, clear, remove,
list.remove(x)
Remove the first item from the list whose value is equal to x.
del statement
del lst[y]
Removes item at index y or slices y from a list or clear the entire list.
del var or del lst or del tup
del can also be used to delete entire variables:
remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del statement can also be used to remove slices from a list or clear the entire list
NIELIT M3-R5 Course 'O' Level Certification,
PG TRB,
TN TRB Assistant Professor Computer Science,
TN TRB AP Computer Science,
TRB AP,
GATE - Data Analytics, GATE - DA,
UGC NET, TANCET MCA, TN SET,
List⇒mutable sequences, typically used to store collections of homogeneous data.
#pythontutorial #pythonforbeginners #pythonlists
#pythonlist
#pythondeveloper #pythoncoding #learnpython
#pythonquiz #python3 #pythonskills #codingpython
#pythonbasics #pythonbeginner #pythonprogramming
#datascience #dataanalytics
#codingquiz #quizchallenge #codingcommunity
#freshers #techtalk #top10
#interviewpreparation #interviewhacks #interviewquestions #interviewskills
Ace your Python exams with this MCQ marathon!
Covers various Python concepts, including input/output, data structures, and more.
#PythonMCQs #PythonInterview #CodingQuiz #PythonProgramming #TechSkills
#ssitlecturestamil @ssitlecturestamilதமிழ்
p=[3,4,5,6]
p[1] = []⇒[3,[],5,6]
p[3:4] = []⇒[3,[],5]
Item Assignment using
Index: lst[i]=itr
→replaces item at i by itr
→No change in list len
i not in range⇒IndexError
Refer,
Index MCQs:66,67
Slice MCQs: 84,85,86
Slice: lst[i:j:k]=itr
→removes items in range
and inserts itr as individual item
→May change list len
With step k,
len slice ≠ len itr⇒ValueError
lst[i:j]=[]⇔del lst[i:j]
→Removes item in range
Non-empty slice with step k, using [],
lst[i:j:k]=[]⇒ValueError
Selective item removal not works
Basic sequence types:
lists, tuples, range.
Additional sequence types:
Text: str
Binary: bytes, bytearray, memoryview.
Mutability: Object's internal state is changeable.
Mutable sequences: Can be changed after creation.
lists, bytearrays
Immutable sequences: Cannot change once created.
tuples, strings, ranges, bytes
Информация по комментариям в разработке