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.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad