Type-C, Programing based questions,
Class-11 Chapter- Tuples Program with solutions,
Q.1– Write a Python program that creates a tuple storing first 9 terms of Fibonacci series.
Q2.(a) Write a program that receives the index and returns the corresponding value.
(b) Write a program that receives a Fibonacci term and returns a number telling which term it is.
Q3. Write a program to input n numbers from the user. Store these numbers in a tuple. Print the maximum and minimum number from this tuple.
Q4. Write a program to create a nested tuple to store roll number, name and marks of students.
Q5. Write a program that interactively creates a nested tuple to store the marks in three subjects for five students. i.e. – marks((45,45,40),(35,40,38),(36,30,38),(25,27,20),(10,15,20))
Q6. In the program created in previous question, add a function that computes total marks and average marks obtained by each student.
Q7. 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.
Q8. Write a program as per following specification :“ return the length of the shortest string in the tuple of a strings str_tuple. Precondition : the tuple will contain at least one element .’”
Q9. Create the following tuple using a for loop :
(i) A tuple containing the squares of the integer 1 though 50 .
(ii) the tuple (“a”, “bb”, “ccc”….)that ends with 26 copies of the letter z .
Q10. 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.
Q11. Write a program that input two tuple seq_a and seq_b and print True if every element in seq_a is also an element of seq_b, else print False.
Q12. Computing Mean. Computing the mean of values stores in a tuple is relatively simple. The mean is the sum of the values divided by the number of values in the tuple. That is,∑x=the sum of x,N=number of elements. Write a program that calculates and displays the mean of a tuple with numeric elements.
Q15. 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.
Информация по комментариям в разработке