Lists, Tuples, and Ditionaries Quiz

Lists, Tuples, and Ditionaries Quiz
Lists, Tuples, and Ditionaries Quiz


Q1 – Predict the right output for the following code.
i = 5
while True:
  if i%9 == 0:
  i += 1

Q2 – Predict the correct output for the following code.
x = “abcdef”
i = “a”
while i in x:
  print(‘i’, end = ” “)

Q3 – Analyse and predict the value of b after the execution of this loop?
b = 0
for a in range(0, 10, 2):
  b += a + 1

Q4 – Select the statement that you can use for iterating over a block of statements N times

Q5 – Analyse and select the statements that correctly explain the output of the given sample code. if(True):
if(” “):
if ([[]]):

Practice Session – Lists

Q1 – Create a list L1 with the elements 1,2,3,4,5,6.


Q2 – Display the third element of the list L1 using negative indexing.


Q3 – Given the list : L1=[1,2,3,4,5,6], how will you display from the third element to the end of the list without specifying the end index?


Q4 – Given the list : L1=[1,2,3,4,5,6], how will you display the third and forth element by specifying positive start and end index ?


Q5 – Given the list : L1=[1,2,3,4,5,6], ll up the code to create a new list L2 that contains only the even numbers from the list L1 using the concept of list comprehension.
L2=[element for element in L1


Practice Session – Tuples

Q1 – Create a tuple (with parenthesis), new_tuple with 5 elements – 101,102,103,104,105.


Q2 – Given the tuple new_tuple = (101, 102, 103, 104,105), how will you display its third element ?

Answer: D


Q3 – Fill up the code pertaining to enumerate method that adds index to the tuple, to bind index with the associated value using a for loop.
for index,tup in  


  print(index, tup)

Practice Session – Dictionaries

Q1 – Create a dictionary – Student_detail with the following key-value pair. Key – Name and Value – Ram.


Q2 – To the dictionary Student_detail, add a new key-value pair. Key – Languages known and Value – English, Tamil, Hindi Student_detail={‘Name’:’Ram’}

Student_detail[‘Languages known’]=[‘English’,’Tamil’,’Hindi’]

Post Quiz

Q1 – Analyse the code and predict the output.
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
  if myList[i] > max:
   max = myList[i]
   indexOfMax = i

Q2 – Evaluate the given code snippet. Ignoring the order, which line of code will you use in the place of “# LINE A” to generate the output shown here ?
keys = [‘key1’, ‘key2’, ‘key3’, ‘key4’, ‘key5’]
vals = [‘val1’, ‘val2’, ‘val3’, ‘val4’, ‘val5’]
# Output: {‘key1’: ‘val1’, ‘key2’: ‘val2’, ‘key3’: ‘val3’, ‘key4’: ‘val4’, ‘key5’: ‘val5’}

Q3 – Evaluate the given code. What is the value pertaining to (a == b, a is b) after the execution ?
a = [1, 2, 3, 1]
b = [1, 2, 3, 1]

Q4 – Describe what will happen during the dictionary update dict[k] = v, if k isn’t present in dict.

Q5 – Select the statement(s) that is/are true.


  1. Pass or Fail
  2. Arrange Names
  3. Create Quarters
  4. Non-Working Doctors
  5. AEIMA’s Online Courses
  6. Search Student Data
  7. Residents Information
  8. Password Protection

1 thought on “Lists, Tuples, and Ditionaries Quiz”

  1. After read a couple of the posts on your site now, and I really like your way of blogging. I tag it to my favorites web site list and will be checking back soon. Please check out my web site as well and let me know your opinion.

Leave a Comment

Your email address will not be published. Required fields are marked *