Question
1. Which of the following creates a tuple? A. tuple1=(a,b) B. tuple1[2]=(a,b) C. tuple1=(5)*2 D. None of the above 2. Choose the correct option with
1. Which of the following creates a tuple?
A. tuple1=("a","b")
B. tuple1[2]=("a","b")
C. tuple1=(5)*2
D. None of the above
2. Choose the correct option with respect to Python.
A. Both tuples and lists are immutable.
B. Tuples are immutable while lists are mutable.
C. Both tuples and lists are mutable.
D. Tuples are mutable while lists are immutable.
3. Choose the correct option.
A. In Python, a tuple can contain only integers as its elements.
B. In Python, a tuple can contain only strings as its elements.
C. In Python, a tuple can contain both integers and strings as its elements.
D. In Python, a tuple can contain either string or integer but not both at a time.
4. What will be the output of below Python code?
tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
A. (5,1,6,2)
B. (5,1,7,6)
C. (5,1,7,6,2)
D. Error
5. What will be the output of below Python code?
tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)
A. (4,8,6)
B. (2,4,3,2,4,3)
C. (2,2,4,4,3,3)
D. Error
6. What will be the output of below Python code?
tupl=("annie","hena","sid")
print(tupl[-3:0])
A. ("annie")
B. ()
C. None
D. Error as slicing is not possible in tuple.
7. Which of the following options will not result in an error when performed on tuples in Python where tupl=(5,2,7,0,3)?
A. tupl[1]=2
B. tupl.append(2)
C. tupl1=tupl+tupl
D. tupl.sort()
8. What will be the output of below Python code?
tupl=()
tupl1=tupl*2
print(len(tupl1))
A. 0
B. 2
C. 1
D. Error as tuple object has no attribute to len
9. What will be the output of below Python code?
tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)
A. ([2,3],"abc",0,9)
B. ([1,3],"abc",0,9)
C. ([2,1],"abc",0,9)
D. Error
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Which of the following creates a tuple Option A is correct tuple1ab This syntax creates a tuple with ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started