#python
#pythonprogramming
Python MCQ Questions and answers,
Python MCQ , Python Programming,
Python, Python Sequence, Python Iterable,
list mutable, Tuple immutable,
list method remove,
del statement
Tuple→immutable
⇒No update operations
t[1:2] = (), t[4] = []
⇒TypeError: 'tuple' object does not support item assignment
t.remove(2)
⇒AttributeError: 'tuple' object has no attribute 'remove'
t[4].remove(2)
t[4]→[2, 4]⇒mutable list⇒[4]
⇒(2, 'T', 'o', 'm', [4], 6)
del t[4]
⇒TypeError: 'tuple' object doesn't support item deletion
del t⇒deletes t
Access of t
⇒NameError: name 't' is not defined.
Tuple immutability,
Mutability of items inside a tuple,
Mutability of mutable Tuple items,
Tuple:
No in-place change of item or structure,
⇒No methods to add or remove items,
⇒Tuple Item assignment using Index, Slice→TypeError
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.
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,
Tuples⇒immutable sequences, typically used to store collections of heterogeneous data.
But tuple can store mutable sequences.
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தமிழ்
If t→list,
t[1:2] = []⇒[2,'o','m',[2,4],6]
t[4] = []⇒[2,'T','o','m',[],6]
t.remove(2)⇒['T','o','m',[2,4],6]
t[4].remove(2)⇒[2,'T','o','m',[4],6]
del t[4]⇒[2,'T','o','m',6]
Refer⇒MCQs 67, 84
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
Информация по комментариям в разработке