The Wayback Machine - https://web.archive.org/web/20250317150811/https://www.geeksforgeeks.org/quizzes/python-tuples-quiz/

Python Tuples Quiz


NA

Last Updated :
Discuss
Comments

Question 1

What is the output of the following program?

Python
tup = (1, 2, 3, 4) 
tup.append( (5, 6, 7) ) 
print(len(tup)) 
  • 1

  • 2

  • 5

  • Error

Question 2

What is the output of the following program?

Python
tup = {} 
tup[(1,2,4)] = 8
tup[(4,2,1)] = 10
tup[(1,2)] = 12
sum1 = 0
for k in tup: 
	sum1 += tup[k] 
print(len(tup) + sum1) 
  • 30

  • 31

  • 32

  • 33

Question 3

What is the output of the following program?

Python
tup1 = (1, 2, 4, 3) 
tup2 = (1, 2, 3, 4) 
print(tup1 < tup2) 
  • Error

  • True

  • False

  • Unexpected

Question 4

What is the output of the following program?

Python
tup = (1, 2, 3) 
print(2 * tup) 
  • (1, 2, 3, 1, 2, 3)

  • (1, 2, 3, 4, 5, 6)

  • (3, 6, 9)

  • Error

Question 5

What is the output of the following program?

Python
tup=("Check")*3
print(tup) 
  • Unexpected

  • 3Check

  • CheckCheckCheck

  • Syntax Error

Question 6

What is the output of the following program?

Python
s = 'geeks' 
a, b, c, d, e = s 
b = c = '*'
s = (a, b, c, d, e) 
print(s) 
  • (‘g’, ‘*’, ‘*’, ‘k’, ‘s’)

  • (‘g’, ‘e’, ‘e’, ‘k’, ‘s’)

  • (‘geeks’, ‘*’, ‘*’)

  • KeyError

Question 7

What is the output of the following program?

Python
tup = (2e-04, True, False, 8, 1.001, True)
val = 0
for x in tup:
    val += int(x)
print(val)
  • 12

  • 11

  • 11.001199999999999

  • TypeError

Question 8

What is the output of the following program?

Python
li = [3, 1, 2, 4] 
tup = ('A', 'b', 'c', 'd') 
li.sort() 
counter = 0
for x in tp: 
	li[counter] += int(x) 
	counter += 1
	break
print(li) 
  • [66, 97, 99, 101]

  • [66, 68, 70, 72]

  • [66, 67, 68, 69]

  • ValueError

Question 9

What is the output of the following program?

Python
li = [2e-04, 'a', False, 87] 
tup = (6.22, 'boy', True, 554) 
for i in range(len(li)): 
	if li[i]: 
		li[i] = li[i] + tup[i] 
	else: 
		tup[i] = li[i] + li[i] 
		break
  • [6.222e-04, ‘aboy’, True, 641]

  • [6.2202, ‘aboy’, 1, 641]

  • TypeError

  • [6.2202, ‘aboy’, False, 87]

Question 10

What is the output of the following program?

Python
import sys 
tup = tuple() 
print(sys.getsizeof(tup), end = " ") 
tup = (1, 2) 
print(sys.getsizeof(tup), end = " ") 
tup = (1, 3, (4, 5)) 
print(sys.getsizeof(tup), end = " ") 
tup = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3)) 
print(sys.getsizeof(tup)) 
  • 0 2 3 10

  • 32 34 35 42

  • 48 64 72 128

  • 48 144 192 480

"This course is very well structured and easy to learn. Anyone with zero experience of data science, python or ML can learn from this. This course makes things so easy that anybody can learn on their own. It's helping me a lot. Thanks for creating such a great course."-  Ayushi Jain | Placed at Microsoft

Now's your chance to unlock high-earning job opportunities as a Data Scientist! Join our Complete Machine Learning & Data Science Program and get a 360-degree learning experience mentored by industry experts.

Get hands on practice with 40+ Industry Projects, regular doubt solving sessions, and much more. Register for the Program today!

There are 11 questions to complete.

Take a part in the ongoing discussion