1. Which of the following creates a tuple? A. tuple1=(a,b) B. tuple1[2]=(a,b) C. tuple1=(5)*2 D. None of...
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 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
Income Tax Fundamentals 2015
ISBN: 9781305177772
33rd Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven Gill