Python Tuple Ws
Python Tuple Ws
WORKSHEET/ASSIGNMENT NO: 1
SESSION: 2024-2025
CLASS/SEC: XI A & XI B
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?
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 ) )
(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
a) t2 = ('a')
type(t2)
(b) t3 = ('a',)
type(t3)
(c) t4 = (17)
type(t4)
(d) t5 = (17,)
type(t5)
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)