80+ Important Tuple Questions in Python for Exams

Share with others

tuple questions in python
Tuple Questions in Python

Tuple Questions in Python Class 11

Tuples CBSE Syllabus : 2021 – 22)

Introduction, indexing, tuple operations (concatenation, repetition, membership & slicing)

Built-in functions: len(), tuple(), count(), index(), sorted(), min(), max(), sum();

Tuple assignment, nested tuple

Suggested programs: finding the minimum, maximum, mean of values stored in a tuple; linear search on a tuple of numbers, counting the frequency of elements in a tuple

tuple questions in python
Tuple Questions in Python

Q1. What do you mean by Tuple in Python?

OR

Q1. Define Tuple

Q2. Write a statement to create an empty tuple named ‘T1’.

Q3. Write a statement to create a tuple ‘T1’ containing first five even numbers.

Q4. Write the code to convert the given list L1 to tuple. L1 = [1, 2, 3, 4, 5]

Q5. Write a statement to create tuple T1 with single element.

Tuple Questions in Python Class 11

Q6. Write the output of the following code :

T1 = (4)
print(type(T1))

Q7. Write the output of the following code :

T1 = 4, 5, 6
print(type(T1))

Q8. Write the output of the following code :

T1 = (1, 2, 3, 4, 5, 6, 7, 8)
print(T1)
print(T1 * 2) 
print(T1 + T1) 
print(len(T1) * 2)

Q9. Write a statement to create tuple T1 with the following data.

1, 4, ‘CS’, ‘IP’, 5

Q10. Write the output of the following code :

T1 = (1, 2, 3, 4, 5, 6, 7, 8)
print(T1[0])
print(T1[-1])
print(T1[2 + 3])
print(T1[4 - 1])
print(T1[7%2])

Tuple Questions in Python Class 11

tuple questions in python
Tuple Questions in Python

Tuple Questions in Python Class 11

Q11. Write the output of the following :

T1 = (1, 2, 3, 4, 5, 6, 7, 8)
print(T1[ : ])
print(T1[3 : ])
print(T1[ : 4])
print(T1[-2 : -5 ])

Q12. Write the output of the following :

T1 = (1, 2, 3, 4, 5, 6, 7, 8)
print(T1[1 : : 2])
print(T1[-1 : -5 : -2])
print(T1[: : -1])
print(T1[ : 7 : 2])

Q13. Which error is returned by the following code :

T1 = (1, 2, 3, 4, 5, 6, 7, 8)
print(T1[15])

Q14. Write two differences between Tuple and List.

Tuple Questions in Python Class 11

Q15. Write a statement in python to concatenate the given tuples.

T1 = (1, 2, 3)

T2 = (5, 6, 7)

Q16. Write the output of the following code :

T1 = (45, 67, 98)
T1 = T1 + (1, 2, 3)
print(T1)

Q17. Write the output of the following code :

T1 = (45, 67, 98)
T1 = T1 * 3
print(T1)

Q18. Write the output of the following code :

T1 = (45, 67, 98)
T2 = ((45, 67, 98))
print(T1 in T2)
print(45 in T2)
print(45 in T1)
print(T1 + T2)

Q19. Explain the following functions in reference to Tuple in Python.

1. len( )

2. count( )

Q20. Write a program to accept five numbers from the user and store it in a tuple ‘T1’.

Tuple Questions in Python Class 11

tuple questions in python
Tuple Questions in Python

Tuple Questions in Python Class 11

Q21. Write a program to accept five fruit name from the user and store it in a tuple ‘F1’.

Q22. Write a program to store ‘n’ number of sports in a tuple ‘S1’. (Accept ‘n’ from the user)

Q23. Consider the following tuple and write the code for the following statements :

T1 = (12, 3, 45, ‘Hockey’, ‘Anil’, (‘a’, ‘b’))

a. Display the first element of ‘T1’

b. Display the last element of ‘T1’

c. Display ‘T1’ in reverse order.

d. Display ‘Anil’ from tuple ‘T1’

e. Display ‘b’ from tuple ‘T1’

Q24. Write the output of the following :

for i in tuple("SHIMLA"):
     print(i + i)

Q25. Write the output of the following :

>>> 7 in tuple(“123456789”)

>>> ‘7’ in tuple(“123456789”)

Tuple Questions in Python Class 11

Q26. Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)
print(len(T1) + T1[-1])
print(T1[T1.count(23) + len(T1) -5])
print(T1.count(T1[6]))
print(T1.count(max(T1)))

Q27. Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)
print(max(T1))
print(min(T1))

Q28. Write the output of the following :

T1 = ('Hockey', 'Cricket', 'Football')
print(max(T1))
print(min(T1))

Q29. Write the output of the following :

T1 = ('Raman', 'Ram', 'Ramaiya')
print(max(T1))
print(min(T1))

Q30. Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)
print(sorted(T1))
print(sorted(T1[2 : 7]))
print(T1.index(23))
print(T1.index(23, 3, 9))

Tuple Questions in Python Class 11

Q31. Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)
 print(sum(max(T1) + min(T1)))

Q32. Write a program to accept three numbers from the user and insert it at the end of given Tuple T1.

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)

Q33. What type of error is returned by following statement :

>>> (a,b,c,d) = (5, 6, 8)

Q34. Write the output of the following code :

>>>(name, rollNo, subject)  = ("Anil", 9, "CS")
>>> name

Q35. Which escape character is used for following :

a. for adding horizontal tab space.

b. for inserting a new line.

Tuple Questions in Python Class 11

Q36. What do you mean by Nested Tuple? Give one example

Q37. Write a statement to print 30 from the given tuple.

a = (“Seventy”, [1, 2, 3], (20, 30, 40), “Eighty”)

Q38. Write a statement to unpack the following tuple into 3 variables.

(60, 70, 80)

Q39. Write a program to swap the values of given tuples.

T1 = (“A”, “B”)

T2 = (34, 65)

Q40. Write the output of the following code :

T1 = ("A",["B","D"],"C")
T1[1][1] = "C"
print(T1)

Tuple Questions in Python Class 11

Q41. Write a program to print the frequency of a number accepted from the user in given tuple : T1 = (12, 17, 18, 25, 19, 12, 18, 5)

Q42. Write a program in python to concatenate all the characters of given tuple. T1 = (‘B’ , ‘O’, ‘O’, ‘K’)

Expected OUTPUT : BOOK

Q43. Write a program to remove a number (accepted from the user) from the given tuple T1 = (12, 15, 18, 21, 24, 27, 30)

SAMPLE EXECUTION

Enter element to remove : 21
Tuple after removing element is  : (12, 15, 18, 24, 27, 30)

Q44. What do you mean by Unpacking Tuple? Give example

Q45. What do you mean by Packing Tuple? Give Example

Tuple Questions in Python Class 11

Q46. Write one similarity between Tuples and String.

Q47. Write the output of the following :

T1 = (2, 'Apple', 6) 
print(max(T1))

Q48. Consider the given tuple and write the output of given statements: T1 = (1, 23, 4, 5, “A”, [“C”, “D”], (23, 45), 45)

  1. print(len(T1))
  2. print(T1.index(45))
  3. print(T1.count(45))
  4. print(T1[5][0]*2)
  5. print(T1[:5])
  6. print(T1[5:])
  7. print(T1.index(“A”))
  8. print(T1[-1 : -7 : -2])
  9. print(T1[4] + T1[5])
  10. print(max(T1))

Q49. Write the length of following tuple :

T1 = (1,(2,3),(((34,56),45,67),39))

Q50. Write a program to store the detail ( Roll number, Name, Section) of three students in a tuple. Accept all data from the user.

SAMPLE OUTPUT : 
((1, 'Amita', 'B'), (2, 'Sunita', 'C'), (3, 'Daya', 'A'))

Tuple Questions in Python Class 11

Q51. Write a program to accept roll number from user and display it’s detail from given tuple

Det=((1, ‘Amita’, ‘B’), (2, ‘Sunita’, ‘C’), (3, ‘Daya’, ‘A’))

Q52. Write a program to accept five numbers from the user and store these numbers in a tuple. Display the following from tuple :

  1. Largest number
  2. Smallest number
  3. Sum of all numbers
  4. Average of all numbers

Q53. Write a program in python to print the second largest element in tuple given below :

T1 = (23, 45, 87, 45, 67, 43, 23, 12)

Q54. Write a program in python to display the sum of all even numbers and odd numbers separately from the tuple given below :

T1 = (24, 45, 87, 46, 67, 44, 23, 12)

Q55. Write the output of the following :

T1 = (“Amit”, “Sumit”)
T2 = “Sumit”, “Amit”
T3 = “Amit”, “Sumit”

print(T1==T2)
print(T1==T3)

Tuple Questions in Python Class 11

Q56. Write a program to accept a number from the user and store first 10 multiples of number in a tuple for example :

SAMPLE OUTPUT :

Enter any number : 4
Tuple =  (4, 8, 12, 16, 20, 24, 28, 32, 36, 40)

Q57. Write a program to accept a string from the user and convert it into tuple. for example

SAMPLE OUTPUT :

Enter any String : tuple 
Tuple = ('t', 'u', 'p', 'l', 'e')

Q58. Write a program to display the sum of all the numbers in a given tuple :

T1 = (1, 2, 3, ‘A’, ‘B’, 4, ‘Sun’)

Q59. Write a program to find the sum of marks of all students stored in the given tuple.

T1 = ((“Suman”, 75),(“Glory” , 35),(“Ravi”,50))

Expected Output is : 160

Q60. Write the output of the following :

T1 = (1, (2, 'a'), (3, 'b', 'c'), (7, 'd', 'e', 'f'))

print(len(T1))

print(T1[1][0])

print(7 in T1[3])

print(T1.index(1))

print(len(T1[3]))

print(T1[T1[2][0]])

Tuple Questions in Python Class 11

Q61. Write the output of the following :

T1 = (1,(2, 'a', (3, 'b', 'c', (7, 'd', 'e', 'f'))))

print(len(T1))

print(T1[1][0])

print(7 in T1[1])

print(T1.index(1))

print(len(T1[1]))

print(T1[T1[0]])

Q62. Write the output of the following :

T1 = (1, (2, 'a') * 2)

print(T1)

print(len(T1))

print(T1[1][1])

print(len(T1[1]))

Q63. Write the output of the following :

T1 = (1, (2, 'a')) * 2

print(T1)

print(len(T1))

print(T1[1][1])

print(len(T1[1]))

print(T1.count(1))

print(T1.index(1))

Q64. Write the output of the following :

T1 = ('a') * 3 
T2 = ('a',) * 3
print(T1)
print(type(T1))
print(len(T1))
print(T2)
print(type(T2))
print(len(T2))

Q65. Write the output of the following :

T1 = "tuple questions in python"

T2 = (T1.split())

print(T1)

print(type(T1))

print(len(T1))

print(T2)

print(T2[0][0] + T2[1][0])

print(len(T2))

Tuple Questions in Python Class 11

Q66. What type of error is returned by following code :

T1 = (1, 2, 3, 4)
T2 = (4, 5, 6)
print(T1 - T2)

Q67. Write the output of the following :

T1 = (1, 2, 3, 4)

print(T1 * 3)

print(T1 * (3))

print((T1) * 3)

print(T1 + (3,))

Q68. Write the output of the following :

T1 = (10, 20, 30)

print((T1, T1, T1))

print(T1, T1, T1)

print((T1 + T1 + T1))

print(T1 * 3)

Q69. Write the output of the following :

a = 30
b = (30)
c = (30,)
print(type(a))
print(type(b))
print(type(c))

Q70. Write a program to accept a number from the user and create a tuple containing all factors of number. for example :

SAMPLE OUTPUT :

Enter any Number : 9
Tuple is : (1, 3, 9)

Tuple Questions in Python Class 11

Q71. Write a program to arrange all the sub tuples of a tuple in increasing order and store them in another tuple. for example

T1 = ((1, 2, 3), (45, 23), (98, 34, 67)) #Original Tuple

T2 = ((1, 2, 3), (23, 45), (34, 67, 98)) #New Tuple

Q72. Write a program to store the length of all sub tuples of a tuple into a new tuple. for example

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9)) #Original Tuple

T2 = (3, 2, 3, 4) # New Tuple

Q73. Write a program to print square of all odd numbers of a tuple.

T1 = (12, 13, 22, 7, 9, 66, 4)

Expected Output : 169, 49, 81

Q74. Write a program to print the common elements of given tuples :

T1 = (1, 2, 3, 4, 5, 6)

T2 = (3, 5, 7, 9, 11)

Expected Output : 3, 5

Q75. Write a program to find the union (Common element include once) of given tuples:

T1 = (1, 2, 3, 4, 5, 6)

T2 = (3, 5, 7, 9, 11)

Expected Output : 1, 2, 3, 4, 5, 6, 7, 9, 11

Tuple Questions in Python Class 11

Q76. Write a program to store the sum of all sub tuples of given tuple into a new tuple. for example

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9)) #Original Tuple

T2 = (6, 68, 199, 177) # New Tuple

Q77. Write a program to store the maximum value of all sub tuples of given tuple into a new tuple. for example

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9),(“A”, “B”, “c”))

#Original Tuple

T2 = (3, 45, 98, 78, c) # New Tuple

Q78. Write a program to display the longest sub tuple from the given tuple.

T1 = ((1, 2, 3), (45, 23), (98, 34, 67), (34, 56, 78, 9)) #

Original Tuple

T2 = (34, 56, 78, 9) # New Tuple

Q79. Write a program to display names starting from vowel from the given tuple.

T1 = (“Amit”, “Ram”, “Esha”, “Harry”)

Q80. Write a program to print the length of all names in a given tuple.

T1 = (“Amit”, “Ram”, “Esha”, “Harry”)

Expected Output : 4, 3, 4, 5

Tuple Questions in Python Class 11

Q81. What is the purpose of following operators in reference to tuples.

a) +

b) *

c) in

Q82. Match the following :

FunctionsDescription
max( )Returns the length of the tuple.
min( )Returns the index value of element in tuple.
count( )Returns the largest element in tuple.
index( )Returns the smallest element in tuple.
len( )Returns the frequency of an element in tuple.
Tuple Questions in Python

Q83. Write the output of the following :

>>> S = 1, (2,3,4,5), 51, (61,71)

>>> len(S)

>>>S[2 : 3]

>>>S[-1][0]

>>>type(S)

Q84. Fill in the blanks in the following code :

import ___________
t = (20, 30, 40, 50, 60, 70)
A = random.randint(1, 3)
B = random.randint(2, 4)
for i _________ range(A, B):
       print (t[i],end= "@")

Tuple Questions in Python Class 11

Disclaimer : I tried to give you the correct answers of ” Tuple Questions in Python” , but if you feel that there is/are mistakes in “Tuple Questions in Python ” given above, you can directly contact me at csiplearninghub@gmail.com.

Tuple Questions in Python Class 11

Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

120 Practice Questions of Computer Network in Python

70 Practice Questions on if-else

40 Practice Questions on Data Structure

Tuple Questions in Python Class 11

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Chapter wise MCQ

Tuple Questions in Python Class 11


Share with others

Leave a Reply

%d bloggers like this: