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
5
Explanation
Mention the use of the split function in Python?
The use of the split function in Python is that it breaks a string into shorter strings using the defined separator.
It gives a list of all words present in the string.
Question
6
Explanation
Differentiate between local and global variables in Python.
Local variables: If a variable is assigned a new value anywhere within the function's body, it's assumed to be local.
Global variables: Those variables that are only referenced inside a function are implicitly global.
Question
7
Explanation
What is the functionality of filter(), map() and reduce() functions?
> filter() – enables you to extract a subset of values based on conditional logic.
> map() – it is a built-in function that applies the function to each item in an iterable.
> reduce() – repeatedly performs a pair-wise reduction on a sequence until a single value is computed.30 Essential
Question
8
Explanation
What is a scope in python?
A scope is a block of code where an object in Python remains relevant. Namespaces uniquely identify all the objects inside a program.
1. A local scope refers to the local objects available in the current function.
2. A global scope refers to the objects available throught the code execution since their inception.
3. A module-level scope refers to the global objects of the current module accessible in the program.
4. An outermost scope refers to all the built-in names callable in the program. The objects in this scope are searched last to find the name referenced.