CBSE Class 12 Computer Science Question 74 of 103

Working with Functions — Question 7

Back to all questions
7
Question

Question 6(i)

What will be the output of following program ?

num = 1
def myfunc():
    return num
print(num)
print(myfunc())
print(num)
Answer
Output
1
1
1
Explanation

The code initializes a global variable num with 1. myfunc just returns this global variable. Hence, all the three print statements print 1.