Python Interview Questions for Fresher

Python Interview Questions for Fresher

Python Interview Questions and Answers for Fresher, by reading this document you can get overall idea on Python programming, and Python Language Fundamentals are covered in this document.

Python Language key features, Python implementations, Python applications, Python environment, Python basic syntax, Python variables & data types, Python operators, Python control flow, Python functions, Python IO, and Python Object Oriented Programming concepts.

1) What is Python?

Python is a Programming language…

Python is not named after the snake Python, The father of Python – Guido Van Rossum said the name of the language was taken from the British comedy series “Monty Python’s Flying Circus”.

Python is a general-purpose, high-level, interpreted, interactive, object-oriented, open source programming language. It was created by Guido Van Rossum in 1989, but publicly released in 1991.

Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. Python official website is (

2) What type of language is Python? Programming or Scripting?

Python is technically a scripting language, but in general sense, it is considered as a general-purpose programming language.

Basically, all scripting languages are programming languages. The theoretical difference between the two is that scripting languages do not require the compilation step and are rather interpreted.

3) What are the key features of Python?

Key features of Python language are:

Free and Open Source:

Python language is freely available at official web address ( source-code is also available, therefore it is open source.

Object-Oriented Language:

Python supports object oriented language and concepts of classes and objects come into existence.

Easy to Learn and Use:

Python is easy to learn and use. It is developer-friendly and high level programming language.

Cross-platform Language:

Python can run equally on different platforms such as Windows, Linux, Unix and Macintosh etc. So, we can say that Python is a portable language.


It can be easily integrated with languages like C, C++, JAVA etc.

Note: Python has so many other features also there, but here I mentioned key features only.

4) What are the different implementations of Python?

Python has a number of alternative implementations are available:

Cpython: The default implementation of the Python programming language is Cpython. As the name suggests Cpython is written in C language.

IronPython: (Python running on .NET)

Jython: (Python running on the Java Virtual Machine)

PyPy: (A fast python implementation with a JIT compiler)

Stackless Python: (Branch of CPython supporting micro-threads)

MicroPython: (Python running on micro controllers)

Anaconda Python: Anaconda is a free and open-source distribution of the Python and R programming languages for scientific computing.

5) What are the various applications/uses of Python?

Python is used to develop:

1. Desktop GUI (Graphical User Interface)
2. Web and Internet Development (IoT – Internet of Things)
3. Games and 3D Graphics
4. Scientific and Numeric Applications
5. Machine Learning and Artificial Intelligence
6. Data Science and Data Visualization
7. Enterprise Applications (Such as e-commerce, ERP and many more.)
8. Network Programming
9. Embedded Applications
10. Audio and Video Applications
11. Education
12. CAD (Computer-Aided Designing) Applications
13. Software Testing / Writing automated tests
14. Python for DevOps / System administration / Writing automation scripts.

6) How is Python an interpreted language?

Python is called an interpreted language because it goes through an interpreter, which turns code you write into the language understood by your computer’s processor.

An interpreted language is any programming language that isn’t already in “machine code” prior to runtime. Unlike compiled languages , an interpreted language’s translation doesn’t happen beforehand. Translation occurs at the same time as the program is being executed.

7) What is PEP 8 in Python?

PEP 8 is Python’s style guide. It’s a set of rules for how to format your Python code to maximize its readability.

PEP-8 (Python Enhancement Proposal) presents some of the key points that you can use to make your code more organized and readable.

8) What is PYTHON PATH?

PYTHONPATH is an environment variable which is used when a module is imported. For most installations, you should not set these variables since they are not needed for Python to run. Python knows where to find its standard library. You can also select Path option while Python installation.

9) How to write & execute Python Programs?

You need have Python Environment to write & execute/run Python programs,

Example: In Windows operating system, download & Install Python software, then you can get Python IDLE, using Python IDLE you can write & execute Python programs, otherwise download & install PyCharm like IDE, and using PyCharm IDE you can write & execute Python programs.

Note: Python IDLE is best for learning and PyCharm IDE is best for real-time use.

10) What is Python IDLE?

Every Python installation comes with an Integrated Development and Learning Environment (IDLE), The Python installer for Windows contains the IDLE module by default. IDLE can be used to execute a single statement just like Python Shell and also to create, modify and execute Python scripts.

Python DLE has the following key features:

> Cross-platform: works mostly the same on Windows, Unix, and MacOS

> Python shell window (interactive interpreter) with colorizing of code input, output, and error messages

> Debugger with persistent breakpoints, stepping, and viewing of global and local namespaces

> Configuration, browsers, and other dialogs

11) How Python is Object Oriented Programming Language?

Python is an object-oriented programming language and it also supports procedural programming.

Python allows us to develop applications using an Object Oriented approach. In Python, we can easily create and use classes and objects.

Python supports all major principles of object-oriented programming system concepts like Object, Class, Method, Inheritance, Polymorphism, Data Abstraction and Encapsulation.

12) What is the Python File extension?

A PY file is a program file or script written in Python, an interpreted object-oriented programming language. It can be created and edited with a text editor, but requires a Python interpreter to run.

13) What are the Python Syntax Basics?

1) Modes of Programming in Python

Python supports Interactive mode and Script mode programming, Interactive mode provides us with a quick way of running blocks or a single line of Python code. If you need to write a long piece of Python code or your Python script spans multiple files, interactive mode is not recommended. Script mode is the way to go in such cases.

2) Python Identifiers

A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_)

3) Reserved Words / keywords

Reserved words (also called keywords) are defined with predefined meaning and syntax in the language. These keywords have to be used to develop programming instructions.

Ex: class, def, if, return, for, while etc….

4) Lines and Indentation

A Python program is divided into a number of logical lines and every logical line is terminated by the token NEWLINE.

Python uses indentation to indicate a block of code.

5) Comments in Python

A hash sign (#) begins a comment, all characters after the # and up to the end of the physical line are part of the comment.

6) Quotation in Python

Python accepts single (‘), double (“) and triple (”’ or “””) quotes to denote string literals, as long as the same type of quote starts and ends the string.

14) How to create/declare Variables in Python?

Variables are containers for storing data values, Python has no command for declaring a variable, A variable is created the moment you first assign a value to it.


a = 5
b = 10.5
c = “India”
d = True


Note: No explicit declaration of Data types in Python, you can store any type of value to a variable, Python considers the data type based on the usage of data, and we can get the data type of any object by using the type() function.


print(type(x)) # int

print(type(y) # str

15) What are Local variables and Global variables in Python?

There are two types of variables in Python, global variables and local variables.

The scope of global variables is the entire program whereas the scope of local variable is limited to the function where it is defined.

16) How to define Data types in Python?

No explicit declaration of Data types in Python, you can store any type of value to a variable, Python considers the data type based on the usage of data, and we can get the data type of any object by using the type() function.

17) How to print Output in Python?

Using print() function (built-in function) we can print the output in Python,


print (“Hello Python”) #Output is Hello Python

print (x) #Output is 100

name=”G C Reddy”
print(“My Name is: ” + name) #Output is G C Reddy

18) How to read User Input in Python?

Using input() function (built-in function) we can read User Input in Python,

val = input(“Enter your value: “)

19) How to insert Comments in Python?

A hash sign (#) begins a comment, all characters after the # and up to the end of the physical line are part of the comment.


#This is a comment

Python does not really have a syntax for multi line comments, You can add a multi-line string (triple quotes) in your code, and place your comment inside it.


This is a comment
written in
more than just one line

20) What are the Python Numbers?

Python supports integers, floating-point numbers and complex numbers. They are defined as int, float, and complex classes in Python.


print(type(a)) #int



python tutorial

Python Programming Language

21) What are the Python Strings?

21) What are docstrings in Python?

22) What are the different types of Operators in Python?

23) What are the Python collections (collection data types)?

24) What is the difference between list and tuple?

25) What is namespace in Python?

26) How to read User Input in Python?

27) How to check data type of a Python variable?

28) How to create a Function in Python?

29) What are different type of Variables in Python?

30) What are Python Identifiers?

31) How to create a Class in Python?

32) What are Modules and Packages in Python?

33) How memory is managed in Python?

34) How to write code blocks in Python?

35) What are Python Condition/Decision blocks in Python?

36) What are Python Loop blocks?

37) What are Python Branching statements?

38) How to call a Python Function?

30) How to create an Object in Python?

40) How to achieve Inheritance in Python?

41) Does python support multiple inheritance?

42) What is Polymorphism in Python?

43) Define Encapsulation in Python?

44) How do you do data abstraction in Python?

45) How to access Databases using Python?

46) What are decorators in Python?

47) What are generators in Python?

48) What is lambda in Python? Why is it used?

49) What is self in Python?

50) How to send an email in Python Language?

To send an email, Python provides smtplib and email modules. Import these modules into the created mail script and send mail by authenticating a user.

G C Reddy

G C Reddy, Working as a Software Testing Trainer in Hyderabad, India.

Leave a Reply

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