1.
a = [10, 20, "GfG", 40, True]
print(a)
print a[0], a[1], a[2], a[4]
print the type of 10 , gfg and True
2. Difference between list and tuple
3. li = [1, 2, 3, 4]
append [5,6,7,8] using append method and extend using extend method
and print both
4. a = [1, 2, 3, 4, 5]
b=a
b[0] = 0;
5. What will be output of a
6.
a = [1998, 2002]
b = [2014, 2016]
print ((a + b)*2)
7. li = ['a', 'b', 'c', 'd', 'e']
print(li[10:] )
8. Find the output of the following program:
a = []
a.append([1, [2, 3], 4])
a.extend([7, 8, 9])
print(a[0][1][1] + a[2])
A
Type Error
B
12
C
11
D
38
9. Given data = (10, 20, 30, 40, 50), what does data[1:4] return?
(10, 20, 30)
(20, 30, 40)
(20, 30, 40, 50)
(10, 20, 30, 40)
10. aTuple = (100, 200, 300, 400, 500)
aTuple.pop(2)
print(aTuple)
11. my_tuple = (1, 2) * 3
print(my_tuple)
12. tup1 = (1, 2, 4, 3)
tup2 = (1, 2, 3, 4)
print(tup1 < tup2)
A. True
B. False
C. Error
D. Unexpected
13.tup = (1, 2, 3)
print(2 * tup)
14. tup1 = (1)
tup2 = (3, 4)
tup1 += 5
print(tup1)
15. Which of the following is not a feature of a tuple?
1. Ordered elements
2. Immutability
3. Does not allow duplicate values
4.Both a and c
16. What will be the output of the following Python code?
t=(1,2,4,3)
print(t[1:3])
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
17. t = (1, 2)
print(2 * t)
a) (1, 2, 1, 2)
b) [1, 2, 1, 2]
c) (1, 1, 2, 2)
d) [1, 1, 2, 2]
18. my_tuple = (1, 2, 3, 4)
my_tuple.append( (5, 6, 7) )
print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
19. print(2**(3**2))
print((2**3)**2)
print(2**3**2)
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
20. names = ['Amir', 'Barun', 'Chirag', 'Rahul']
print(names[-1][-1])
a) A
b) Rahul
c) Error
d) l