Question: 1 -
Choose the correct option with respect to Python.
-
Tuples are immutable while lists are mutable.
-
Tuples are mutable while lists are immutable.
-
Both tuples and lists are mutable.
-
Both tuples and lists are immutable.
Answer:
Tuples are immutable while lists are mutable.
Solution not available.
Question: 2 -
What will be the output of below Python code?tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)
-
(4,8,6)
-
(2,4,3,2,4,3)
-
(2,2,4,4,3,3)
-
Error
Answer:
(2,4,3,2,4,3)
Solution not available.
Question: 3 -
What will be the output of below Python code?tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
-
(5,1,7,6)
-
Error
-
(5,1,6,2)
-
(5,1,7,6,2)
Answer:
Error
Solution not available.
Question: 4 -
Choose the correct option.
-
In Python, a tuple can contain only integers as its elements.
-
In Python, a tuple can contain only strings as its elements.
-
In Python, a tuple can contain both integers and strings as its elements.
-
In Python, a tuple can contain either string or integer but not both at a time.
Answer:
In Python, a tuple can contain both integers and strings as its elements.
Solution not available.
Question: 5 -
Which of the following creates a tuple?
-
tuple1=(5)*2
-
tuple1[2]=("a","b")
-
None of the above
-
tuple1=("a","b")
Answer:
tuple1=("a","b")