Top 121 PYTHON Interview Questions and Answers:
- December 11, 2020
- Posted by: AtoZ Trainings
- Category: Interview Questions

1) What is the python language?
A) Python is a general purpose, object oriented programing language and python syntax is very simple and readable language.
2) What are benefits /advantages in python?
A) Python is must for students and working professional and python language is interactive and GUI (Graphical User Interphase) language.
3) What is Python Path?
A) Adding Python to Windows Path in 2 ways.
- Via installation of recent / latest version of python.
- Manual entry of the paths.
4) What is python interpreter?
A) Python interpreter takes the code that you write and converts into language that computer can understand and human readable.
Interpreter executes line by line (asynchronous timers).
5) Is the Python Object Oriented Programming?
A) Yes, python is strictly object oriented programing language is intuitive high level, multi paradigm programing language it supports multiple programing language and cross platform, free and open source technology.
6) What are the data types in python?
A) Python data types 6 types
- Strings
- Number
- List
- Tuple
- Set
- Dictionary
7) How to install python in mac and windows?
A) Open python official website (python.org) and click download button and find the right version python language as per our system configuration and the right one and double click on application and follow the instruction.
8) What is pip in python?
A) Pip stands for python package index. Python package are not part of the standard library and pip enables third party package index.
Pip come with by default in the latest version of python.
9) How to install python package (PIP)?
A) Using simple Command you can install, pip –m install.
10) How to comment multiple lines in python?
A) In python language u can comment code with the # symbol.
Example: # this is the python comment, python comment will Ignore the code and content.
11) What is pep 8?
A) Pip stands for python enhancement proposal (pep 8) and pep the latest version is 8. Pep 8 holds great community generated proposals.
12) What is the latest python version?
A) Present latest version of python is 3.9.1 . We can check the python version by using this command (python -version).
13) What are data type’s supporters?
A) Python data types are of 6 types.
- Strings
- Number
- List
- Tuple
- Set
- Dictionary
14) What is PYTHONPATH?
A) Python path is an environment variable which is used when a module is imported. Whenever a module is imported, PYTHONPATH is also looked up to check for the presence of the imported modules in various directories. The interpreter uses it to determine which module to load.
15) Is python case sensitive?
A) Yes, Python is a case sensitive language.
16) What is type conversion & list out some of in Python?
A) Type conversion refers to the conversion of one data type to another data type.
Some of the type conversions bellow:
- int() – converts any data type into integer type
- float() – converts any data type into float type
- list() – This function is used to convert any data type to a list type.
- str() – This function Used to convert integer into a string.
- complex(real, image) – This function converts real numbers to complex(real, imag) number.
17) How to change capitalize the first letter of string?
A) In Python, the capitalize() method capitalizes the first letter of a string. If a string already consists of a capital letter at the beginning, then, it returns to the original string.
18) Can you convert a string to all lowercase, give some example?
A) To convert a string to lowercase, lower() function can be used.
Example:
my_string = ‘This is Python Lowercase String’
Print(my_string.lowercase())
19) What is PEP 8?
A) Pep 8 is a style guide & set of recommendations from the community, about how to write Python code more readable & easier to understand. We use this bring consistency in our code; with consistency it is easier for other developers to read the code.
20) What are the built-in types in python?
A) They are of two types mutable and immutable
Mutable built-in types are:
- List
- Sets
- Dictionaries
Immutable built-in types are:
- Strings
- Tuples
- Numbers
21) What are supported data types in python?
A) Python has five supported data types
- Numbers
- String
- List
- Tuple
- Dictionary
22) How to remove last object from a list?
A) To remove and return last object or object from list use this command;
list.list.pop(obj=list[-1])
23) What is slicing in Python?
A) Slicing is a string operation for extracting a part of the string, or some part of a list items. It can also perform reverse indexing, i.e., in the backward direction, with the help of negative numbers. It is a mechanism to select a range of items from sequence types like list, tuple, strings etc.
24) What Is %s in Python?
A) Python has supported for formatting any value into a string. It may contain quite complex expressions. One of the common usages is to push values into a string with the %s format specifier. The formatting operation in Python has the comparable syntax as the C function printf() has.
25) How can you copy an object in Python?
A) To copy an object in Python,
- you can try copy.copy () or copy.deepcopy() for the general case.
- You cannot copy all objects but most of them.
26) Explain how to convert a number to a string?
A) To convert a number into a string, we can use the inbuilt function str(). For octal or hexadecimal representation, use the inbuilt function oct() or hex().
def convert_num_to_str(num):
str_num = str(num)
return str_num
# def convert_num_to_str(3) –> should return “3”
Author:Yoktha
Leave a Reply Cancel reply
You must be logged in to post a comment.