top of page
  • Facebook
  • Twitter
  • Instagram

Top Python Interview Questions

Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement handbooks also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.

Question

21

Explanation

How list is different from tuple in python?

> List are mutable (editable) while Tuple is immutable which can’t be edited.
> Lists are slower when compared with Tuples.
> List can have multiple data type in the single list where it can’t happen while using a tuple.
> Syntax: list = [1,’python’, 2.0] Syntax: tuple = [1, 2, 3]

Question

22

Explanation

What is a dictionary in python?

Dictionary is one of the built-in datatype in python which is represented with key and corresponding values to it. These are indexed based on keys.
Example: Dict = {‘Name’: ‘Arjun’, ‘Age’: 21, ‘School’: ‘KVS’}
print (Dict [Name]) >O/P: Arjun
print (Dict [Age]) >O/P: 21
print (Dict [School’]) >O/P: KVS
In the above example Name, Age and School are Keys whereas the O/P are the corresponding values assigned to that keys.

Question

23

Explanation

Explain inheritence in python programming.

As Python follows an object-oriented programming paradigm, classes in Python have the ability to inherit the properties of another class. This process is known as inheritance. Inheritance provides the code reusability feature. The class that is being inherited is called a superclass and the class that inherits the superclass is called a derived or child class.
Following types of inheritance are supported in Python:
> Single inheritance: When a class inherits only one superclass
> Multiple inheritance: When a class inherits multiple superclasses
> Multilevel inheritance: When a class inherits a superclass and then another class inherits this derived class forming a ‘parent, child, and grandchild’ class structure
> Hierarchical inheritance: When one superclass is inherited by multiple derived classes

Question

24

Explanation

Write a python code to count the number of Capital letters in a file.

with open(A_LARGE_FILE) as countletter:
count = 0
text = countletter.read()
for character in text:
if character.isupper():
count += 1

bottom of page