Class 11 CS Chapter 12 Tuples Solutions Sumita Arora New Syllabus / Uncategorized / By Neha Exercise 12.1 11. What does a + b amount to if a is a tuple and b = 5 ? ...click here for answer 1. Why are tuples called immutable types ? ...click here for answer 2. What are mutable counterparts of tuples ? ...click here for answer 3. What are different ways of creating tuples ? ...click here for answer 4. What values can we have in a tuple ? Do they all have to be the same type* ? ...click here for answer 5. How are individual elements of tuples accessed ? ...click here for answer 6 . How do you create the following tuples ? ...click here for answer 8. Can you change an element of a sequence ? What if the sequence is a dictionary ? What if the sequence is a tuple ? ...click here for answer 9. What does a + b amount to if a and b are tuples ? ...click here for answer 10. What does a * b amount to if a and b are tuples ? ...click here for answer 12. Is a string the same as a tuple of characters ? ...click here for answer 13. Can you have an integer, a string, a tuple of integers and a tuple of strings in a tuple ? ...click here for answer Back Exercise Part A 2. If a is (1,2, 3) ...click here for answer 1. Discuss the utility and significance of Tuples, briefly. ...click here for answer 3. Does the slice operator always produce a new tuple ? ...click here for answer 4. The syntax for a tuple with a single item is simply the element enclosed in a pair of matching parentheses as shown below : ...click here for answer 5. Are the following two assignments same ? Why / why not ? ...click here for answer 6. What would following statements print ? Given that we have tuple = (‘t’, ‘p’, ‘l’) ...click here for answer 7. How is an empty tuple created ? ...click here for answer 8. How is a tuple containing just one element created ? A tuple ...click here for answer 9. How can you add an extra element to a tuple ? ...click here for answer 10. When would you prefer tuples over lists ? ...click here for answer 11. What is the difference between (30) and (30,) ? ...click here for answer Back Exercise Part B 1. Find the output generated by following code fragments : ...click here for answer 2. What does each of the following expressions evaluate to? Suppose that T is the tuple containing : ...click here for answer 3. Carefully read the given code fragments and figure out the errors that the code may produce. ...click here for answer 4. What would be the output of following code if ntpl = (“Hello”, “Nita”, “How’s”, “life?”) ...click here for answer 5. Predict the output. ...click here for answer 6. Predict the output. ...click here for answer 7. Find the error. Following code intends to create a tuple with three identical strings. But even after successfully executing following code (No error reported by Python), The len() returns a value different from 3. Why ? tup1 = ...click here for answer 8. Predict the output ...click here for answer 9. What will the following code produce ? ...click here for answer 10. What will be the output of the following code snippet ? ...click here for answer Back Exercise Part C 2. ...click here for answer 3. Write a program that interactively creates a nested tuple to store the marks in three subjects for five students, i.e., tuple will look somewhat like : ...click here for answer 4. In the program created in previous question, add a function that computes total marks and average marks obtained by each student. ...click here for answer 5. Write a program that inputs two tuples and creates a third, that contains all elements of the first followed by all elements of the second. ...click here for answer 6. Write a program as per following specification : ...click here for answer 7. Create the following tuples using a for loop : ...click here for answer 8. Given a tuple pairs = ((2, 5), (4, 2), (9, 8), (12,10)), count the number of pairs (a, b) such that both a and b are even. ...click here for answer 9. Write a program that inputs two tuples seq_a and seq_b and prints True if every element in seq_a is also an element of seq_b, else prints False. ...click here for answer 10. Computing Mean. Computing the mean of values stored in a tuple is relatively simple. The mean is the sum o f the values divided by the number o f values in the tuple. That is, # Code ...click here for answer 11. Mean of means. Given a nested tuple tup1 = ( (1, 2), (3, 4.15, 5.15), ( 7, 8, 12, 15)). Write a program that displays the means of individual elements of tuple tup1 and then displays the mean of these computed means . That is for above tuple, it should display as : Mean element ...click here for answer 1. Write a Python program that creates a tuple storing first 9 terms of Fibonacci series. # Code ...click here for answer