Ans (b) because tuple is immutable.
T = (20,5,16,29,83)
What will be the problem with the code
T[1]=100.
Ans It will show error tuple is immutable.
Suppose a tuple T is declared as
T = (10, 20, 30, 40),
what will be the output of
print(T*2)
Ans 20,40,60,80
print(t1.index(4))
output is
a). 4 b). 5 c). 6 d). 2 Ans (d) 2
What is the length of the tuple shown below?
t=(((('a',1),'b','c'),'d',2),'e',3)
Ans 3
A tuple is declared as T = (2,5,6,9,8)
What will be the value of sum(T)? Ans 30
Which of the following statements will create
a tuple ?
(a) Tp1 = (“a”, “b”) (b) Tp1= (3) * 3
(c) Tp1[2] = (“a”, “b”) (d) None of these
Ans (a)
Find the output of the following:
>>>S = 1, (2,3,4), 5, (6,7)
>>> len(S)
Ans 4
Identify the valid declaration of Rec:
Rec=(1,‟Vikrant”,50000)
(i)List (ii)Tuple
(iii)String (iv)Dictionary
Ans (ii) Tuple
T = (1,2), (1,2,4), (5,3)
What will be the value of min(T) ? Ans (1,2)
Consider the tuple in python named
DAYS=(”SUN”,”MON”,”TUES”)
Identify the invalid statement(s) from the
given below statements:
a). S=DAYS[1] b). print(DAYS[2])
c). DAYS[0]=”WED” d). LIST=list(DAYS)
Ans (c) DAYS[0]=”WED”
Suppose a tuple Tup is declared as
Tup = (12, 15, 63, 80),
which of the following is incorrect?
a) print(Tup[1]) b) Tup[2] = 90
c) print(min(Tup)) d) print(len(Tup))
Ans (b) Tup[2]=90
What is the output of the following code:
for i in range(-3,4,2):
print(i, end = '$')
Ans -3$-1$ 1$ 3$
If a is (1, 2, 3), what is the difference (if any) between
a*3 and [a, a, a]?
Ans:
a*3 is different from [a,a,a] because, a*3 will
produce a tuple (1,2,3,1,2,3,1,2,3) and [a, a, a]
will
produce a list of tuples [(1,2,3),(1,2,3),(1,2,3)].
If a is (1, 2, 3), is a *3 equivalent to a + a+ a?
Does a slice operator always produce a new Tuple?
How is an empty Tuple created?
How is a tuple containing just one element created?
Ans:
T=3,
or
T=(4,)
What is the difference between (30) and
(30,)?
Ans:
(30) is an integer while (30,) is a tuple
G=’a’,’b’
H=(‘a’,’b’)
print(G==H) Ans True
T=(1,)*3
T[0]=2
print(T)
Ans typeError. Tuple is immutable so can’t
do changes