• +91 9971497814
• info@interviewmaterial.com

# Chapter 13- Lists, Dictionaries and Tuples Interview Questions Answers

### Related Subjects

Question 1 :
How many types of built-in types of sequences in Python.

Python has six built-in types of sequences.

Question 2 :
Write the output of the given Python code.

# !/user/bin/python
list1 = [‘physics’, ‘chemistry’, 1997, 2000];
list2 = [1,2,3,4,5,6, 7];
print “list1[0]”, list1[0]

list1[0]: physics

Question 3 :
How can we remove list element ?

To remove a list element, you can use either the del statement or the remove]) method

Question 4 :
Why we use cmp(listl, list2) in Python?

It compares elements of both lists.

Question 5 :
Describe max(list) method.

It returns item from the list with max value.

Question 6 :
Describe min(list) method.

It returns item from the list with min value.

Question 7 :
What do you mean by list.count(obj)

Returns count how many times obj occurs in list

Question 8 :
Is list.reverse() method return a value?

This method does not return any value but reverse the given object from the list

Question 9 :
Define list in Python.

The list is a most versatile datatype available in Python which can be written as a list of comma- separated values (items) between square brackets. Good thing about a list is that items in a list need not all have the same type. Creating a list is as simple as putting different comma-separated values between square brackets.
For example :
list1 = [‘physics’, ‘chemistry’, 1997,2000];
list2 = [1,2, 3,4, 5];
list3 = ’[‘a”, “b”, “c”, “d”];

Question 10 :
Give an example to access values in lists.

To access value in lists, use the square brackets for slicking along with the index or indices to obtain value available at that index. Following is a simple example :

# !/user/bin/python
list1 = [‘physics’, ‘chemistry’, 1997, 2000];
list2 = [1, 2, 3, 4, 5, 6, 7];
print “list1 [0]:”,
list1 [0] print “list2[1 :5]:”, list2[1:5]

When the above code is executed, it produces the following result:

list1 [0]: physics
list2[1:5] : [2, 3, 4, 5]

krishan