Python Interview Questions: Ans: .Py Files Contain The Source Code of A Program. Whereas, .Pyc File Contains
Python Interview Questions: Ans: .Py Files Contain The Source Code of A Program. Whereas, .Pyc File Contains
Ans:
Break Statement terminates the Loop immediately.(Come out of a loop)
Pass : insert an empty block
Example:
pat = [1, 3, 2, 1, 2, 3, 1, 0, 1, 3]
for p in pat:
pass
if (p == 0):
current = p
break
elif (p % 2 == 0):
continue
One very important condition a recursive function should have to be used in a program is, it should
terminate, else there would be a problem of an infinite loop
11. Which python built in module can be used to perform operation such as deleting or rename
a file?
Ans: Built in module called “os”
def sum_of_twonumbers(a,b):
print(a+b)
13. Name any python modules which can be used to remotely SSH
15. What are negative indexes and why are they used?
Ans: Negative indexes are the indexes from the end of the list or tuple or string. They cab be used to
access ending elements of list or tuple.
Ans: An Interpreted language executes its statements line by line. Languages such as Python,
Javascript, R, PHP and Ruby are prime examples of Interpreted languages. Programs written in an
interpreted language runs directly from the source code, with no intermediary compilation step.
Local Namespace includes local names inside a function. the namespace is temporarily created for a
function call and gets cleared when the function returns.
Global Namespace includes names from various imported packages/ modules that is being used in
the current project. This namespace is created when the package is imported in the script and lasts
until the execution of the script.
Built-in Namespace includes built-in functions of core Python and built-in names for various types of
exceptions.