Page 1 - Home Assignment - TUPLE
P. 1
Home Assignment
Computer Science
Class – XI
Topic: TUPLES
1. Which of the following is not a Python tuple?
a) ('a', 'b', 'c') b) (1, 2, 3) c) ([1, 2], ['ONE', 'TWO']) d) [(1,2), (2,3)]
2. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))
3. What will be the output of the follwoing?
a) print((2,4,6,8,10)[2:])
b) x=(1,)+(2,)+('a',)+('b',)
print(x)
c) print(len(([1,2],'abc',('pqr','xyz'))))
d) print(([1,2],'abc',('pqr','xyz'))[2][1][0])
e) print((2,3,4)<(2,3,5))
f) (10, 20, 30).extend((40, 50))
4. Explain the process packing and unpacking by taking a suitable example.
5. Write a Python program to create a tuple (elements should be user input of mixed type).
Print the tuple and also print the number of elements of the tuple.
6. Write a Python program that creates a tuple storing (1!, 2!, 3!,…., N!), N is user input.
7. Write a Python program that creates a third tuple after concatenating two tuples. Join
second after the first tuple.
8. Write a Python program to calculate the mean of the numbers of the numeric tuple.
9. Write a Python program to find the repeated items of a tuple.
10. Write a Python program to find the index of an item of a tuple.