Identify the following function definitions as void or non-void function.
(i) def fun():
print(“Hello!”)
(ii) def fun():
print(“Hello!”)
return,
(iii) def fun():
print(“Hello!”)
return(1)
(iv) def fun():
return(2)
print(“Hello”)
Answer:
- Void functions are those functions that do not return any value or don't have a return statement.
- Non-void functions always return a value.
Therefore, (i) an (ii) are void functions and (iii) and (iv) are non-void functions.