Python Viva Voice Questions
Python Viva Voice Questions
Lists and Tuples are both sequence data types that can store
a collection of objects in Python. The objects stored in both
sequences can have different data types. Lists are represented
with square brackets ['sara', 6, 0.19], while tuples are
represented with parantheses ('ansh', 5, 0.97).
But what is the real difference between the two? The key
difference between the two is that while lists are
mutable, tuples on the other hand are immutable objects. This
means that lists can be modified, appended or sliced on the go
but tuples remain constant and cannot be modified in any
manner.
A local scope refers to the local objects available in the current
function.
A global scope refers to the objects available throughout the
code execution since their inception.
Lists, tuples and sets are all used to store multiple items in a
single variable.
A list is a collection of data which is ordered and changeable
(elements can be added, removed and changed).
A tuple is a collection of data which is ordered and
unchangeable (elements cannot be added, removed or
changed).
A set is a collection of data which is unordered,
unchangeable, and unindexed.