0% found this document useful (0 votes)
4 views21 pages

Python List, Tuple, Dictionary

The document presents 30 exercises focused on Python's List, Tuple, and Dictionary data types, aimed at enhancing programming skills. It includes definitions, example questions, and answers to help users understand and apply these fundamental concepts. Additionally, the document offers a resource for 100 Python interview questions for further practice.

Uploaded by

shaanravi133
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views21 pages

Python List, Tuple, Dictionary

The document presents 30 exercises focused on Python's List, Tuple, and Dictionary data types, aimed at enhancing programming skills. It includes definitions, example questions, and answers to help users understand and apply these fundamental concepts. Additionally, the document offers a resource for 100 Python interview questions for further practice.

Uploaded by

shaanravi133
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Python List, Tuple, Dictionary Exercises (10 Each)


By Meenakshi Agarwal No Comments 2 months ago
Last updated: Nov 30, 2025 10:37 pm

Ready to test your Python skills? Solve 30 most critical Python


programming questions on List, Tuple, and Dictionary – the foundation of
every Python application. Gain a deep understanding of these data types
and take your coding to the next level.

Python Programming Q & A – List, Tuple, and Dictionary


By the end of this tutorial, confidently use List, Tuple, and Dictionary data
types to supercharge your Python projects. Let’s dive in and unlock your
Python potential!

We hope you are ready to start this 30-question questionnaire. However,


we have also curated the best 100 Python interview questions on various
Python programming topics. Please save this list of 100 questions and
check it out after you finish the 30 questions on List, Tuple, and
Dictionary.

[Link] 1/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

10 Objective questions and answers on the list


Before getting started with the questions on Python lists, check out a
short definition of a list in Python. It will help you remember about it
quickly.

What is a list type in Python?


A list, in Python, stores a sequence of objects in a defined order. Python
lists allow indexing and iterating through its elements. Lists are mutable
objects that you can modify after creation.

Q-1. What will be the output of the following Python code?

Run

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

A. [1,2]
B. [8,9]
C. [1,3,5,7,9]
D. [1,2,3]

Answer 1 Single Choice

1 2 3 4

0/1 correct

Q-2. The code below manipulates a Python list using the slicing operator.
What will be the output?

Run

list = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
list [:: 2 ] = 10 , 20 , 30 , 40 , 50 , 60
print ( list )

[Link] 2/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

A. ValueError: Attempt to assign a sequence of size 6 to an extended slice


of size 5
B. [10, 2, 20, 4, 30, 6, 40, 8, 50, 60]
C. [1, 2, 10, 20, 30, 40, 50, 60]
D. [1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]

Answer 2 Single Choice

1 2 3 4

0/1 correct

Q-3. What will be the output of the following code snippet?

Run

list = [ 1 , 2 , 3 , 4 , 5 ]
print ( list [ 3 : 0 :- 1 ])

A. Syntax error
B. [4, 3, 2]
C. [4, 3]
D. [4, 3, 2, 1]

Answer 3 Single Choice

1 2 3 4

0/1 correct

Q-4. What will the Python function in the code below do? Choose the right
option.

Run

def f ( value , values ):


values [ value ] = 44

[Link] 3/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

value = 0

t = 3
v = [1, 2, 3, 4]
f(t, v)

print ( t , v [ t ])

A. 1 44
B. 3 1
C. 3 44
D. 1 1

Answer 4 Single Choice

1 2 3 4

0/1 correct

Q-5. What is the correct command to shuffle the given Python list?

fruit_list = [ 'apple' , 'banana' , 'papaya' , 'cherry' ]

A. [Link]()
B. shuffle(fruit)
C. [Link](fruit)
D. [Link](fruit)

Answer 5 Single Choice

1 2 3 4

0/1 correct

[Link] 4/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Q-6. The function below is iterating over a nested Python list. What will it
return?

Run

listoflists = [[[ 1 , 2 ], [ 3 , 4 ]], [[ 5 , 6 ], [ 7 , 8 ]]]

def fun ( m ):
v = m [ 0 ][ 0 ]
for row in m :
for element in row :
if v < element : v = element
return v

print ( fun ( listoflists [ 0 ]))

A. 1
B. 2
C. 3
D. 4
E. 5
F. 6

Answer 6 Single Choice

1 2 3 4 5 6

0/1 correct

Q-7. The below code is iterating over a nested Python list. What will be the
output?

Run

listoflists = [[ 1 , 2 , 3 , 4 ],
[ 4 , 5 , 6 , 7 ],
[ 8 , 9 , 10 , 11 ],
[ 12 , 13 , 14 , 15 ]]
[Link] 5/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

for i in range ( 0 , 4 ):
print ( listoflists [ i ]. pop ())

A. 1 2 3 4
B. 1 4 8 12
C. 4 7 11 15
D. 12,13,14,15

Answer 7 Single Choice

1 2 3 4

0/1 correct

Q-8. What will be the output of the following Python code?

Run

def f ( i , values = []):


values . append ( i )
print ( values )
return values
f(1)
f(2)
f(3)

A. [1] [2] [3]


B. [1, 2, 3]
C. [1] [1, 2] [1, 2, 3]
D. 1 2 3

Answer 8 Single Choice

1 2 3 4

0/1 correct
[Link] 6/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Q-9. The code below uses a Python list and iterates using the range()
function. What will be the output?

Run

list = [ 1 , 2 , 3 , 4 , 5 , 6 ]
for i in range ( 1 , 6 ):
list [ i - 1 ] = list [ i ]
for i in range ( 0 , 6 ):
print ( list [ i ], end = " " )

A. 1 2 3 4 5 6
B. 2 3 4 5 6 1
C. 1 1 2 3 4 5
D. 2 3 4 5 6 6

Answer 9 Single Choice

1 2 3 4

0/1 correct

Q-10. What will be the output of the following code snippet?

Run

fruit_list1 = [ 'Apple' , 'Berry' , 'Cherry' , 'Papaya' ]


fruit_list2 = fruit_list1
fruit_list3 = fruit_list1 [:]

fruit_list2 [ 0 ] = 'Guava'
fruit_list3 [ 1 ] = 'Kiwi'

sum = 0
for ls in ( fruit_list1 , fruit_list2 , fruit_list3 ):
if ls [ 0 ] == 'Guava' :
sum += 1
if ls [ 1 ] == 'Kiwi' :

[Link] 7/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

sum += 20

print ( sum )

A. 22
B. 21
C. 0
D. 43

Answer 10 Single Choice

1 2 3 4

0/1 correct

Do you know how to traverse multiple lists in parallel? Learn Python zip
function to iterate lists in parallel.

✓ Python Progress Tracker

🎯 10/30 exercises mastered 33% Milestone

You’ve completed the List challenges with flying colors!


What’s your next coding adventure?

🌊 Python Tutorials for Beginners

🌀 Python Exercises for Beginners

Let’s take up 10 questions on Python tuples!

Before you dive in to solve the questions below, quickly have a bird-view
on the concept of a tuple in Python.

[Link] 8/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

What is a tuple in Python?


A tuple is similar to a list, but it’s immutable. Another semantic difference
between a list and a tuple is that “Tuples are heterogeneous data
structures whereas the list is a homogeneous sequence.”.

Q-1. What will be the output of the following Python code?

Run

init_tuple = ()
print ( init_tuple . __len__ ())

A. None
B. 1
C. 0
D. Exception

Answer 11 Single Choice

1 2 3 4

0/1 correct

Q-2. What will be the output of the following Python coding snippet?

Run

init_tuple_a = 'a' , 'b'


init_tuple_b = ( 'a' , 'b' )

print ( init_tuple_a == init_tuple_b )

A. 0
B. 1
C. False
D. True

[Link] 9/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Answer 12 Single Choice

1 2 3 4

0/1 correct

Q-3. What will be the output of the following code snippet?

Run

init_tuple_a = '1' , '2'


init_tuple_b = ( '3' , '4' )

print ( init_tuple_a + init_tuple_b )

A. (1, 2, 3, 4)
B. (‘1’, ‘2’, ‘3’, ‘4’)
C. [‘1’, ‘2’, ‘3’, ‘4’]
D. None

Answer 13 Single Choice

1 2 3 4

0/1 correct

Q-4. What will be the output of the following code snippet?

Run

init_tuple_a = 1 , 2
init_tuple_b = ( 3 , 4 )

[ print ( sum ( x )) for x in [ init_tuple_a + init_tuple_b ]]

A. Nothing gets printed.


B. 4
[Link] 10/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

C. 10
D. TypeError: unsupported operand type

Answer 14 Single Choice

1 2 3 4

0/1 correct

Q-5. What will be the output of the following code snippet?

Run

init_tuple = [( 0 , 1 ), ( 1 , 2 ), ( 2 , 3 )]

result = sum ( n for _ , n in init_tuple )

print ( result )

A. 3
B. 6
C. 9
D. Nothing gets printed.

Answer 15 Single Choice

1 2 3 4

0/1 correct

Q-6. Which of the following statements given below is/are true about a
Python tuple?

A. Tuples have structure, and lists have an order.


B. Tuples are homogeneous, and lists are heterogeneous.
C. Tuples are immutable, and lists are mutable.
D. All of them.

[Link] 11/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Answer 16 Multiple Choice

1 2 3 4

0/2 correct

Q-7. What will be the output of the following code snippet?

Run

list = [ 1 , 2 , 3 ]

init_tuple = ( 'Python' ,) * ( list . __len__ () - list [::- 1 ][ 0 ])

print ( init_tuple )

A. ()
B. (‘Python’)
C. (‘Python’, ‘Python’)
D. Runtime Exception.

Answer 17 Single Choice

1 2 3 4

0/1 correct

Q-8. What will be the output of the following code using a Python tuple?

Run

init_tuple = ( 'Python' ) * 3

print ( type ( init_tuple ))

A. <class ‘tuple’>
B. <class ‘str’>
[Link] 12/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

C. <class ‘list’>
D. <class ‘function’>

Answer 18 Single Choice

1 2 3 4

0/1 correct

Q-9. What will be the output of the following code snippet?

Run

init_tuple = ( 1 ,) * 3

init_tuple [ 0 ] = 2

print ( init_tuple )

A. (1, 1, 1)
B. (2, 2, 2)
C. (2, 1, 1)
D. TypeError: ‘tuple’ object does not support item assignment

Answer 19 Single Choice

1 2 3 4

0/1 correct

Q-10. What will be the output of the following Python code?

Run

init_tuple = (( 1 , 2 ),) * 7

print ( len ( init_tuple [ 3 : 8 ]))

[Link] 13/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

A. Exception
B. 5
C. 4
D. None

Answer 20 Single Choice

1 2 3 4

0/1 correct

🏆 66% Complete

You’re Crushing It!

20/30 challenges conquered! Just 10 more to unlock Python


mastery.

Finish Strong →

Finally, you have completed 20 Python programming questions on lists


and tuples. Don’t skip the last 10 questions related to the dictionary data
type.

Let’s not miss 10 more questions on dictionaries.

Here is a short description of a dictionary in Python to let you understand


it quickly.

What is a dictionar y type in Python?


Dictionaries in Python are collections of elements in the form of key-value
pairs. They are unordered by default and use hash tables for indexing.
Search operations are generally faster in a dictionary as keys are hashed,
allowing for efficient lookups.

Q-1. What is the output of the below Python code?


[Link] 14/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Run

dict = {( 1 , 2 ): 1 ,( 2 , 3 ): 2 }
print ( dict [ 1 , 2 ])

A. Key Error
B. 1
C. {(2,3):2}
D. {(1,2):1}

Answer 21 Single Choice

1 2 3 4

0/1 correct

Q-2. What will be the output of the following Python coding snippet?

Run

dict = { 'a' : 1 , 'b' : 2 , 'c' : 3 }


print ( dict [ 'a' , 'b' ])

A. Key Error
B. [1,2]
C. {‘a’:1,’b’:2}
D. (1,2)

Answer 22 Single Choice

1 2 3 4

0/1 correct

Q-3. The code below has a Python function writing to a dictionary. What
will it print in the end?
[Link] 15/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

Run

fruit_dict = {}

def addone ( index ):


if index in fruit_dict :
fruit_dict [ index ] += 1
else :
fruit_dict [ index ] = 1

addone ( 'Apple' )
addone ( 'Banana' )
addone ( 'apple' )
print ( len ( fruit_dict ))

A. 1
B. 2
C. 3
D. 4

Answer 23 Single Choice

1 2 3 4

0/1 correct

Q-4. What will be the output of the following Python coding snippet?

Run

dict = {}
dict [ 1 ] = 1
dict [ '1' ] = 2
dict [ 1 ] += 1

sum = 0
for k in dict :
sum += dict [ k ]

[Link] 16/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

print ( sum )

A. 1
B. 2
C. 3
D. 4

Answer 24 Single Choice

1 2 3 4

0/1 correct

Q-5. How will the Python dictionary in the below code behave? Choose
the right answer.

Run

dict = {}
dict [ 1 ] = 1
dict [ '1' ] = 2
dict [ 1 . 0 ] = 4

sum = 0
for k in dict :
sum += dict [ k ]

print ( sum )

A. 7
B. Syntax error
C. 3
D. 6

Answer 25 Single Choice

[Link] 17/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

1 2 3 4

0/1 correct

Q-6. What will be the output of the following code snippet?

Run

dict = {}
dict [( 1 , 2 , 4 )] = 8
dict [( 4 , 2 , 1 )] = 10
dict [( 1 , 2 )] = 12

sum = 0
for k in dict :
sum += dict [ k ]

print ( sum )
print ( dict )

A. Syntax error
B. 30
{(1, 2): 12, (4, 2, 1): 10, (1, 2, 4): 8}
C. 47
{(1, 2): 12, (4, 2, 1): 10, (1, 2, 4): 8}
D. 30
{[1, 2]: 12, [4, 2, 1]: 10, [1, 2, 4]: 8}

Answer 26 Single Choice

1 2 3 4

0/1 correct

Q-7. What will the following Python dictionary code print in its result?

Run

[Link] 18/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

box = {}
jars = {}
crates = {}
box [ 'biscuit' ] = 1
box [ 'cake' ] = 3
jars [ 'jam' ] = 4
crates [ 'box' ] = box
crates [ 'jars' ] = jars
print ( len ( crates [ box ]))

A. 1
B. 3
C. 4
D. Type Error

Answer 27 Single Choice

1 2 3 4

0/1 correct

Q-8. What will be the output of the Python code given below?

Run

dict = { 'c' : 97 , 'a' : 96 , 'b' : 98 }

for _ in sorted ( dict ):


print ( dict [ _ ])

A. 96 98 97
B. 96 97 98
C. 98 97 96
D. NameError

Answer 28 Single Choice

[Link] 19/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

1 2 3 4

0/1 correct

Q-9. Will the ID of a copied Python dictionary object change? Check your
answer.

Run

rec = { "Name" : "Python" , "Age" : "20" }


r = rec . copy ()
print ( id ( r ) == id ( rec ))

A. True
B. False
C. 0
D. 1

Answer 29 Single Choice

1 2 3 4

0/1 correct

Q-10. What will be the result of the below Python code?

Run

rec = { "Name" : "Python Programmer" , "Age" : "20" , "Addr" : "NJ" , "Count


id1 = id ( rec )
del rec
rec = { "Name" : "Python Programmer" , "Age" : "20" , "Addr" : "NJ" , "Count
id2 = id ( rec )
print ( id1 == id2 )

 

[Link] 20/21
2/7/26, 10:42 AM Python List, Tuple, Dictionary 30 Exercises - TechBeamers

A. True
B. False
C. 1
D. Exception

Answer 30 Single Choice

1 2 3 4

0/1 correct

Summary – Python Programming Questions [List, Tuple, and


Dictionary]
We tried to address some of the key Python programming constructs in
this post with the help of 30 quick questions on Lists, Tuples, and
Dictionaries. We hope you would’ve enjoyed them all.

In the next post, we’ll discuss another interesting Python programming


topic. Till then, enjoy reading and keep learning.

Finally, to keep our site free, we need your support. If you found this
tutorial helpful, please share it on Linkedin or Facebook.

Enjoy Coding,
TechBeamers

[Link] 21/21

You might also like