ASTER PUBLIC SCHOOL, GREATER NOIDA
WORKSHEET/ASSIGNMENT NO: 1
SESSION: 2024-2025
CLASS/SEC: XI A & XI B
SUBJECT: COMPUTER SCIENCE TOPIC: TUPLE IN PYTHON
SUBJECT TEACHER: MS. ASIMA CHAKRABARTY
Q1 A tuple is declared as
T = (2,66,77,55,6,9,55,8)
Write the output of
print(T.index(55))
(i) 4 (ii) 3 (iii) 55 (iv) None of these.
Q2 Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is Incorrect?
a) print( T[1] ) b) print(max(T))
c) print(len(T)) d) None of the these
Q3 If tup=(20,30,40,50), which of the following is incorrect ?
i. print(tup[3]) ii. tup[2]=55
iii. print(max(tup)) iv. print(len(tup))
Q4 Consider two tuples given below:
>>>tup1=(1,2,4,3)
>>>tup2=(1,2,3,4)
What will the following statement print(tup1<tup2) ?
i. True ii. False iii. Error iv. None of these
Q5 Which function returns the number of elements in the tuple
i. len( ) ii. max( ) iii. min( ) iv. count( )
Q6 Which of the following is correct to insert a single element in a tuple .
i. T=9 ii. T=(9) iii. T(9,) iv. T=[9,]
Q7 Rahul has created the a tuple containing some numbers as
>>>t=(10,20,30,40)
now he wants to do the following things help him
He want to add a new element 60 in the tuple, which statement he should use out of the given four?
i . >>> t+(80)
ii. >>> t + 80
iii. >>>t + (80,)
iv. >>>t + (‘80’)
Q8 t=(1,2,3,4)
Write the statement should be used to print the first three elements 3 times?
i. >>>print(t*3)
ii. >>>t*3
iii. >>>t[:3]*3
iv. >>>t+t
Q9 Type error occurs while statement 2 is running. Give reason. How can it be corrected?
>>> tuple1 = (5) #statement 1
>>> len(tuple1) #statement 2
Q 10 What will be stored in variables a, b, c, d, e, f, g, h after following statements?
perc = (88, 85, 80, 88, 83, 86)
a = perc[2:2]
b = perc[2:]
c = perc[:2]
d = perc[:-2]
e = perc[-2]
f = perc[2:-2]
g = perc[-2:2]
h = perc[:]
Q 11 Match the output with the statement given in column A with Column B
1. >>>tuple([10,20,30]) a. >>> (10,20,30)
2. >>>(“Tea”,)* 3 b. >>> 2
3. >>>tuple(“Item”) c. >>> ('Tea', 'Tea', 'Tea')
4. >>>print(len(tuple([1,2]))) d. >>> ('I', 't', 'e', 'm')
i. 1-b,2-c,3-d,4-a
ii. 1-a,2-c,3-d,4-b
iii. 1-c,2-d,3-a,4-a
iv. 1-d,2-a,3-b,4-c
Q 12 tuple1= (23,1,45,67,45,9,55,45)
tuple2= (100, 200)
Find the output of the following.
i. print(tuple1.index(45))
ii. print(tuple1.count(45))
iii. print(tuple1 + tuple2)
iv. print(len(tuple2))
v. print(max(tuple1))
vi print(min(tuple1))
vii. print(sum(tuple2))
viii. print( sorted ( tuple1 ) )
Q 13. Find the output generated by following code fragments:
(i)
plane = ("passengers", "luggage")
plane[1] = "snakes"
(b)
(a, b, c) = (1, 2, 3)
(c)
(a, b, c, d) = (1, 2, 3)
(d)
a, b, c, d = (1, 2, 3)
(e)
a, b, c, d, e = (p, q, r, s, t) = t1
Q 14 What will be the values and types of variables a, b, c, d, e, f, p, q, r, s, t after executing
the following?
a, b, c, d, e = (p, q, r, s, t) = t1
Predict the output.
a) t2 = ('a')
type(t2)
(b) t3 = ('a',)
type(t3)
(c) t4 = (17)
type(t4)
(d) t5 = (17,)
type(t5)
Q 15 Write the output of the following.
a)
tuple = ('a', 'b', 'c', 'd', 'e')
tuple = ('a',) + tuple [1:]
print (tuple)
b)
t2 = (4, 5, 6)
t3 = (6, 7)
t4 = t3 + t2
t5 = t2 + t3
print(t4)
print(t5)
c)
t3 = (6, 7)
t4 = t3 * 3
t5 = t3 * (3)
print(t4)
print(t5)
d)
t1 = (3, 4)
t2 = ('3', '4')
print(t1 + t2)