tuples in python class 11

tuples in python Important Questions

class 11

tuples in python

Q 1. How are tuples different from list when both are sequences ?

Q 2. How can you say that a tuple is an ordered list of objects ?

Q 3. Following code is trying to create a tuple with a single item. But when we try to obtain the length of the tuple is, Python gives error. Why? What is the solution?

Q 4. What is the length of the tuple shown below ?
t = ((((‘a’), ‘b’, ‘c’), ‘d’, 2), ‘e’, 3)

Q 5. Can tuple be nested. ?

Q 6. Given a tuple namely cars storing car names as element :

(‘Toyota’, ‘Honda’, ‘GM’, ‘Ford’, ‘BMW’, ‘Volkswagon’, ‘Mercedes’, ‘Ferrai’, ‘porshe’)

Write a program to print names of the cars in index range 2 to 6, both inclusive.
The output should also include the index in words as shown below :
One Honda
Two GM

Q 7. Given a tuple T(1, 2, “a”, “b”). There is a list L with some elements. Replace first four elements of list with all four elements of the tuple in single statement. Print the list before and after the list is modified.