MCQs > IT & Programming > Python > Output of the following Python code? a = 1 def f(): print (a+2) def g(): a = 2 print (a+1) def h(): global a a = 3 print (a+3) print (a+4) f() print (a+2) g() print (a+1) h() print (a+2)

Python MCQs

What will be the correct output of the following Python code?

a = 1

def f():

print (a+2)

def g():

a = 2

print (a+1)

def h():

global a

a = 3

print (a+3)

print (a+4)

f()

print (a+2)

g()

print (a+1)

h()

print (a+2)


Answer

Correct Answer:

5

3

3

3

2

6

5


Explanation:

Note: This Question is unanswered, help us to find answer for this one

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it