Python Interview Questions
Python Interview Questions
Python is a dynamic-typed language. It means that you don’t need to mention the data type
of variables during their declaration.
Python supports object-orientated programming as you can define classes along with the
composition and inheritance.
Functions in Python are like first-class objects. It suggests you can assign them to
variables, return from other methods and pass them as arguments.
Developing using Python is quick but running it is often slower than compiled languages.
Python has several usages like web-based applications, test automation, data modeling, big
data analytics, and much more.
Global Variables: Variables declared outside a function or in a global space are called global
variables. These variables can be accessed by any function in the program.
Local Variables: Any variable declared inside a function is known as a local variable. This
variable is present in the local space and not in the global space.
https://protechstack.com/interview/python-interview-questions 1/4
10/07/2025, 23:02 Python Interview Questions
Negative numbers mean that you count from the right instead of the left. So, list[-1] refers to the
last element, list[-2] is the second-last, and so on.
How do I modify
Python a string
Interview in python?
Questions Junior
ProTechStack
You can’t because Hire. In most
strings are immutable in python Posts
situations,Interview About
you should simply construct
ProTechStack
a new string from the various parts you want to assemble it from. Work with them as lists; turn
them into strings only when needed.
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'z', 'o', 'r', 'l', 'd']
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
>>> "".join(s)
'Hello World'
A Lambda Function is a small anonymous function. A lambda function can take any number of
arguments, but can only have one expression.
Consider:
x = lambda a : a + 10
print(x(5)) # Output: 15
To convert the string into a number the built-in functions are used like int() a constructor. It is
a data type that is used like int (‘1’) == 1.
https://protechstack.com/interview/python-interview-questions 2/4
10/07/2025, 23:02 Python Interview Questions
The number by default are interpreted as a decimal and if it is represented by int(‘0x1’) then
it gives an error as ValueError. In this the int(string,base) the function takes the parameter
to convert string to number in this the process will be like int(‘0x1’,16) == 16. If the base
parameter is defined as 0 then it is indicated by octal and 0x indicates it as a hexadecimal
number.
There is function eval() that can be used to convert a string into number but it is a bit slower
and present many security risks
req.message:'Hello'
next()
Job posting alerts from top platforms like Linkedin, Naukri, Monster, Google Careers
etc in one place
https://protechstack.com/interview/python-interview-questions 3/4
10/07/2025, 23:02 Python Interview Questions
Copyright © 2024 - ProTechStack Terms of Service Privacy and Cookies Refunds & Cancellation Pricing
https://protechstack.com/interview/python-interview-questions 4/4