MCQ Answer

<p>What will be printed?</p><pre><span style="font-size: 14px;">x = 10<br></span><span style="font-size: 14px;">def f():<br></span><span style="font-size: 14px;">&nbsp; &nbsp; x = 20<br></span><span style="font-size: 14px;">&nbsp; &nbsp; print(x)<br></span><span style="font-size: 14px;">f()<br></span><span style="font-size: 14px;">print(x)</span></pre>

What will be printed?

x = 10
def f():
    x = 20
    print(x)
f()
print(x)


निम्न code का output क्या होगा?

x = 10
def f():
    x = 20
    print(x)
f()
print(x)
Topic : Functions in Python

A. 10 10

B. 20 20

C. 20 10

D. Error




Correct Answer is :

C. 20 10



Explanation
<p><span style="font-size: 14px;">The x inside f() is local (20), while the outside x remains 10.</span></p><p><span style="font-size: 14px;"><br></span></p><p><span style="font-size: 14px;">Function के अंदर x local variable है जिसकी value 20 है, जबकि global x की value 10 ही रहती है।</span></p>
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad