• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Python Tuples Quiz

Question 1

Question 1: What is the output of the following program? Python3
tuple = (1, 2, 3, 4) 
tuple.append( (5, 6, 7) ) 
print(len(my_tuple)) 
  • 1
  • 2
  • 5
  • Error

Question 2

Question 2: What is the output of the following program? Python3
tuple = {} 
tuple[(1,2,4)] = 8
tuple[(4,2,1)] = 10
tuple[(1,2)] = 12
_sum = 0
for k in tuple: 
	_sum += tuple[k] 
print(len(tuple) + _sum) 
  • 30
  • 31
  • 32
  • 33

Question 3

Question 3: What is the output of the following program? Python3
tuple1 = (1, 2, 4, 3) 
tuple2 = (1, 2, 3, 4) 
print(tuple1 < tuple2) 
  • Error
  • True
  • False
  • Unexpected

Question 4

Question 4: What is the output of the following program? Python3
tuple = (1, 2, 3) 
print(2 * tuple) 
  • (1, 2, 3, 1, 2, 3)
  • (1, 2, 3, 4, 5, 6)
  • (3, 6, 9)
  • Error

Question 5

Question 5: What is the output of the following program? Python3
tuple=(\"Check\")*3
print(tuple) 
  • Unexpected
  • 3Check
  • CheckCheckCheck
  • Syntax Error

Question 6

Question 6: What is the output of the following program? Python3
T = \'geeks\' 
a, b, c, d, e = T 
b = c = \'*\'
T = (a, b, c, d, e) 
print(T) 
  • (‘g’, ‘*’, ‘*’, ‘k’, ‘s’)
  • (‘g’, ‘e’, ‘e’, ‘k’, ‘s’)
  • (‘geeks’, ‘*’, ‘*’)
  • KeyError

Question 7

Question 7: What is the output of the following program? Python3
T = (2e-04, True, False, 8, 1.001, True)
val = 0
for x in T:
    val += int(x)
print(val)
  • 12
  • 11
  • 11.001199999999999
  • TypeError

Question 8

Question 9: What is the output of the following program? Python3
L = [3, 1, 2, 4] 
T = (\'A\', \'b\', \'c\', \'d\') 
L.sort() 
counter = 0
for x in T: 
	L[counter] += int(x) 
	counter += 1
	break
print(L) 
  • [66, 97, 99, 101]
  • [66, 68, 70, 72]
  • [66, 67, 68, 69]
  • ValueError

Question 9

Question 8: What is the output of the following program? Python3
L = [2e-04, \'a\', False, 87] 
T = (6.22, \'boy\', True, 554) 
for i in range(len(L)): 
	if L[i]: 
		L[i] = L[i] + T[i] 
	else: 
		T[i] = L[i] + T[i] 
		break
  • [6.222e-04, ‘aboy’, True, 641]
  • [6.2202, ‘aboy’, 1, 641]
  • TypeError
  • [6.2202, ‘aboy’, False, 87]

Question 10

Question 10: What is the output of the following program? Python3
import sys 
L1 = tuple() 
print(sys.getsizeof(L1), end = \" \") 
L1 = (1, 2) 
print(sys.getsizeof(L1), end = \" \") 
L1 = (1, 3, (4, 5)) 
print(sys.getsizeof(L1), end = \" \") 
L1 = (1, 2, 3, 4, 5, [3, 4], \'p\', \'8\', 9.777, (1, 3)) 
print(sys.getsizeof(L1)) 
  • 0 2 3 10
  • 32 34 35 42
  • 48 64 72 128
  • 48 144 192 480

There are 11 questions to complete.

Last Updated :
Take a part in the ongoing discussion