Q. What will be the output of the following programs?
(i)
num = 1
def myfunc ():
return num
print(num)
print(myFunc())
print(num)
(ii)
num = 1
def myfunc():
num = 10
return num
print (num)
print(myfunc())
print(num)
(iii)
num = 1
def myfunc ():
global num
num = 10
return num
print (num)
print(myfunc())
print(num)
(iv)
def display():
print("Hello", end = ' ')
display()
print("there!")
Answer =
(i)
Output:-
1
Error: - NameError: name 'myFunc' is not defined
(ii)
Output:-
1
10
1
(iii)
Output:-
1
10
10
(iv)
Output:-
Hello there!
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )