Python Interview Questions PDF
Python Interview Questions PDF
Python programming language has become popular with desktop application development. It has become a
must skill set on most of the companies’ requirements in a developer. Python programming language has
become popular with machine learning community and is a basic need skill for data scientist/machine-learning
developer/deep-learning developer. This article helps you through most of the upto date possible Python
interview questions; and covers basic, intermediate and advanced Python interview questions. Example
programs and references are provided whenever possible.
Interpreted (most of its implementations execute instructions directly, without previously compiling a program into machine
level instructions)
High-level programming language (provides strong abstraction from internal details of computer; and is human
readable)
General-purpose programming language (the language could be used to write wide variety of applications)
sample.py
i=10
print(i)
Python Shell
$ python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Python Version
$ python --version
Python 3.5.2
Boolean
Numeric
int
float
long
complex
Sequence
String
List
Tuple
Set
Mapping
Dictionary
Like other functional programming languages, Python has following conditional statements.
Python If
Python If-Else
Python For
Python While
Python For
Python While
Python If Syntax
if condition:
statement1
statement2
statementN
for is keyword
sequence can be a list, string, typle or rance
for ith iteration, the ith element of sequence is loaded to variable
statements has to written with indentation
Tuple Examples
tuple1 = ('Sarath', 'Varma', 1997, 'Kochi')
tuple2 = (1, 2, 3, 4, 5 )
Multiple Line Comments are enclosed between triple single quotes or triple double quotes.
Python Comments
# single line commenet
'''Mulitpl
Line
Commnet'''
"""Another
Multiple line
comment"""
def displayStudent(self):
print "Name : ", self.name, ", Roll Number: ", self.rollNumber
The Student class contains a constructor for setting the initial state and a method to display student information.
Python 2.x or 3.x. Which one would you choose and why ?
Python 2.x is legacy, Python 3.x is the present and future of the language.
List
Sets
Dictionaries
Strings
Tuples
Numbers
Array Initialization
arr1 = [10, 20, 30, 40, 50]
arr1[0];
arr1[2];
arr1[1:]
for i in arr1:
print(i);
arr1 = [{10, 20, 30, 40, 50},{10, 20, 30, 40, 50}]
print(len(arr1))
print(len(arr1[0]))
Python Programming
Python Tutorial
Get Started
Install Python
Python Variables
Python Comments
Control Statements
Python If
Python If Else
Functions
Python Functions
Advanced
Python Multithreading
Useful Resources