Q. What will following code print?


def addEm(x, y, z):
    print (x + y + z)
def prod (x, y, z):
    return x * y * z

a = addEm (6, 16, 26)
b = prod (2, 3, 6)
print(a, b)


Why did Python not report an error when void functions do not return a value?


Answer :-

Output :-

48
None 36

>>>

Reason :-


Void function :- addEm()

Non-void function :- prod()

In Python, void functions do not return a value; rather they report the absence of returning value by returning None, which is legal empty value in Python. Thus, variable a stores None and it is not any error.

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post