Report Bug

Qus

What will be the output of the following Python code?

def f(): x=4  x=1  f()  x
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. Error
B. 4
C. Junk value
D. 1


Solution
D. 1



Explanation
In the code shown above, when we call the function f, a new namespace is created. The assignment x=4 is performed in the local namespace and does not affect the global namespace. Hence the output is 1.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad