# 80+ Important Tuple Questions in Python for Exams

Share with others

## 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

OR

## 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)```

## Q10. Write the output of the following code :

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

## 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)```

## 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)```

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

```Show AnswerAns.

T1 = ()
i =0
while(i<5):
num = int(input("Enter any number : "))
T1 = T1 + (num,)
i = i+1
print(T1)

OUTPUT : # You can enter any other number

Enter any number : 1
Enter any number : 2
Enter any number : 3
Enter any number : 4
Enter any number : 5
(1, 2, 3, 4, 5)```

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

```Show AnswerAns.

F1 = ()
i =0
while(i<5):
frnm = input("Enter any fruit name : ")
F1 = F1 + (frnm,)
i = i+1
print(F1)

OUTPUT # You can enter any other fruit name

Enter any fruit name : Apple
Enter any fruit name : Mango
Enter any fruit name : Banana
Enter any fruit name : Grapes
Enter any fruit name : Kiwi
('Apple', 'Mango', 'Banana', 'Grapes', 'Kiwi')```

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

```Show AnswerAns.

S1 = ()
n = int(input("How many sports you want enter : "))
i =0
while(i<n):
spnm = input("Enter sport name : ")
S1 = S1 + (spnm,)
i = i+1
print(S1)

OUTPUT :

How many sports you want enter : 3
Enter sport name : Hockey
Enter sport name : Cricket
Enter sport name : Football
('Hockey', 'Cricket', 'Football')```

## 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)```

## 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))
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))```
```Show AnswerAns.

23
2```

## Q28. Write the output of the following :

```T1 = ('Hockey', 'Cricket', 'Football')
print(max(T1))
print(min(T1))```
```Show AnswerAns.

Hockey
Cricket
```

## Q29. Write the output of the following :

```T1 = ('Raman', 'Ram', 'Ramaiya')
print(max(T1))
print(min(T1))```
```Show AnswerAns.

Raman
Ram```

## 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))```
```Show AnswerAns.

[2, 4, 5, 7, 9, 10, 12, 23, 23, 23, 32]
[2, 4, 5, 12, 23]
0
6```

## 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)))```

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

```Show AnswerAns.

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)
t=( )
for i in range(3):
n1 = int(input("Enter any number : "))
t=t+(n1,)
T1=T1 + t
print(T1)

OUTPUT :

Enter any number : 26
Enter any number : 27
Enter any number : 28
(23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23, 26, 27, 28)```

## Q34. Write the output of the following code :

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

## T2 = (34, 65)

```Show AnswerAns.

T1 = ("A", "B")
T2 = (34, 65)
T1, T2 = T2, T1
print("T1 = ", T1)
print("T2 = ", T2)

OUTPUT :

T1 =  (34, 65)
T2 =  ('A', 'B')```

## Q40. Write the output of the following code :

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

## 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)

```Show AnswerAns.

T1 = (12, 17, 18, 25, 19, 12, 18, 5)
n1 = int(input("Enter any number : "))
print(T1.count(n1))

OUTPUT :

Enter any number : 12
2```

## Expected OUTPUT : BOOK

```Show AnswerAns.

T1 =('B' , 'O', 'O', 'K')
st = ""
for i in T1:
st = st + i
print(st)

OR

T1 =('B' , 'O', 'O', 'K')
st = "".join(T1)
print(st)```

## 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)```
```Show AnswerAns.

T1 = (12, 15, 18, 21, 24, 27, 30)
el = int(input("Enter the element to be removed : "))
if el in T1:
L = list(T1)
L.remove(el)
T1 = tuple(L)
print(T1)
else:

OUTPUT :

Enter the element to be removed : 21
(12, 15, 18, 24, 27, 30)```

## 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*2)
5. print(T1[:5])
6. print(T1[5:])
7. print(T1.index(“A”))
8. print(T1[-1 : -7 : -2])
9. print(T1 + T1)
10. print(max(T1))
```Show AnswerAns.

1. 8
2. 7
3. 1
4. CC
5. (1, 23, 4, 5, 'A')
6. (['C', 'D'], (23, 45), 45)
7. 4
8. (45, ['C', 'D'], 5)
9. Error
10. Error```

## 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'))```
```Show AnswerAns.

Det = ()
tmp=()
for i in range(3):
rn = int(input("Enter Roll number : "))
nm = input("Enter name of student : ")
sec = input("Enter Section of student : ")
tmp = (rn, nm, sec)
Det=Det + (tmp,)
print(Det)

Enter Roll number : 1
Enter name of student : Amita
Enter Section of student : B
Enter Roll number : 2
Enter name of student : Sunita
Enter Section of student : C
Enter Roll number : 3
Enter name of student : Daya
Enter Section of student : A
((1, 'Amita', 'B'), (2, 'Sunita', 'C'), (3, 'Daya', 'A'))```

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

```Show AnswerAns.

Det=((1, 'Amita', 'B'), (2, 'Sunita', 'C'), (3, 'Daya', 'A'))
rn = int(input("Enter Roll number : "))
k=0
for i in range(3):
if rn==Det[i]:
print(Det[i])
k=1
break
if k==0:

OUTPUT :

Enter Roll number : 2
(2, 'Sunita', 'C')

Enter Roll number : 8

## 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
```Show AnswerAns.

t = ()
for i in range(5):
n1 = int(input("Enter any number : "))
t = t + (n1,)
print("Largest Number is : ", max(t))
print("Smallest Number is : ", min(t))
print("Sum of all Numbers is : ", sum(t))
print("Average is : ", sum(t)/5)

OUTPUT :

Enter any number : 1
Enter any number : 2
Enter any number : 3
Enter any number : 4
Enter any number : 5

Largest Number is :  5
Smallest Number is :  1
Sum of all Numbers is :  15
Average is :  3.0```

## 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)

```Show AnswerAns.

T1 = (23, 45, 87, 45, 85, 43, 23, 12)
T1=sorted(T1)
print(T1[-2])```

## 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)

```Show AnswerAns.

T1 = (24, 45, 87, 46, 67, 44, 23, 12)
se=0
so=0
for i in T1:
if i%2==0:
se = se + i
else:
so = so + i
print("Sum of even numbers are : ", se)
print("Sum of odd numbers are : ", so)```

## Q55. Write the output of the following :

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

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

```Show AnswerAns.

False
True```

## 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)```
```Show AnswerAns.

n1 = int(input("Enter any number : "))
t = ( )
for i in range(1,11):
t = t + (n1*i,)
print("Tuple = ",t)```

## 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')```
```Show AnswerAns.

str = input("Enter any String : ")
T1 = tuple(str)
print(T1)```

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

```Show AnswerAns.

T1 = (1, 2, 3, 'A', 'B', 4, 'Sun')
s = 0
for i in T1:
if str(i).isdigit( ):
s = s + i
print("Sum is = ",s)

OUTPUT :

Sum is = 10```

## Expected Output is : 160

```Show AnswerAns.

T1 = (("Suman",75), ("Glory" , 35), ("Ravi",50))
s = 0
for i in T1:
s = s + i
print("Sum of marks = ",s)```

## Q60. Write the output of the following :

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

print(len(T1))

print(T1)

print(7 in T1)

print(T1.index(1))

print(len(T1))

print(T1[T1])```
```Show AnswerAns.

4
2
True
0
4
(7, 'd', 'e', 'f')```

## Q61. Write the output of the following :

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

print(len(T1))

print(T1)

print(7 in T1)

print(T1.index(1))

print(len(T1))

print(T1[T1])```
```Show AnswerAns.

2
2
False
0
3
(2, 'a', (3, 'b', 'c', (7, 'd', 'e', 'f')))```

## Q62. Write the output of the following :

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

print(T1)

print(len(T1))

print(T1)

print(len(T1))```
```Show AnswerAns.

(1, (2, 'a', 2, 'a'))
2
a
4```

## Q63. Write the output of the following :

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

print(T1)

print(len(T1))

print(T1)

print(len(T1))

print(T1.count(1))

print(T1.index(1))```
```Show AnswerAns.

(1, (2, 'a'), 1, (2, 'a'))
4
a
2
2
0```

## 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))```
```Show AnswerAns.

aaa
<class 'str'>
3
('a', 'a', 'a')
<class 'tuple'>
3```

## 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 + T2)

print(len(T2))```
```Show AnswerAns.

tuple questions in python
<class 'str'>
25
['tuple', 'questions', 'in', 'python']
tq
4```

## 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,))```
```Show AnswerAns.

(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)
(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)
(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)
(1, 2, 3, 4, 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)```
```Show AnswerAns.

((10, 20, 30), (10, 20, 30), (10, 20, 30))
(10, 20, 30) (10, 20, 30) (10, 20, 30)
(10, 20, 30, 10, 20, 30, 10, 20, 30)
(10, 20, 30, 10, 20, 30, 10, 20, 30)```

## Q69. Write the output of the following :

```a = 30
b = (30)
c = (30,)
print(type(a))
print(type(b))
print(type(c))```
```Show AnswerAns.

<class 'int'>
<class 'int'>
<class 'tuple'>
```

## 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)```
```Show AnswerAns.

n1 = int(input("Enter any Number : "))
t = ( )
for i in range(1,n1+1):
if n1%i == 0:
t = t + (i,)
print("Tuple is : ",t)```

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

```Show AnswerAns.

T1 = ((1, 2, 3),(45, 23), (98, 34, 67))
T2 = ()
for i in T1:
T2 = T2 + (tuple(sorted(i)),)
print(T2)```

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

```Show AnswerAns.

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9))
T2 = ()
for i in T1:
T2 = T2 + (len(i),)
print(T2)```

## Expected Output : 169, 49, 81

```Show AnswerAns.

T1 = (12, 13, 22, 7, 9, 66, 4)
for i in T1:
if i%2 != 0:
print(i * i, end= " ")```

## Expected Output : 3, 5

```Show AnswerAns.

T1 = (1, 2, 3, 4, 5, 6)
T2 = (3, 5, 7, 9, 11)
for i in T1 :
if i in T2:
print(i, end = "")```

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

```Show AnswerAns.

T1 = (1, 2, 3, 4, 5, 6)
T2 = (3, 5, 7, 9, 11)
T3 = T1
for i in T2 :
if i not in T1:
T1 = T1 + (i,)
print(T1)```

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

```Show AnswerAns.

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9))
T2 = ( )
for i in T1:
T2 = T2 + (sum ( i ), )
print(T2)```

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

```Show AnswerAns.

T1 = ((1, 2, 3), (45, 23), (98, 34, 67), (34, 56, 78, 9), ("A", "B", "c"))
T2 = ()
for i in T1:
T2 = T2 + (max (i),)
print(T2)```

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

```Show AnswerAns.

T1 = ((1, 2, 3), (45, 23), (98, 34, 67),(34, 56, 78, 9),("A", "B", "c"))
T2 = ()
for i in T1:
T2 = T2 + (len (i),)
ind = T2.index(max(T2))
print(T1[ind])```

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

```Show AnswerAns.

T1 = ("Amit", "Ram", "Esha", "Harry")
for i in T1:
if i in ("aeiouAEIOU"):
print(i)

OUTPUT :

Amit
Esha```

## Expected Output : 4, 3, 4, 5

```Show AnswerAns

T1 = ("Amit", "Ram", "Esha", "Harry")
for i in T1:
print(len(i),end=", ")```

## >>>type(S)

```Show AnswerAns.

4
51
61
<class 'tuple'```

## 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= "@")```
```Show AnswerAns.

import random
t = (20, 30, 40, 50, 60, 70)
A = random.randint(1,3)
B = random.randint(2,4)
for i in 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

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