Non-value-returning functions, also known as procedures or void functions, are called for their side effects rather than for a return value. Such function calls are treated as statements and can be used anywhere an executable statement is appropriate.
Example:
Consider a function that displays a welcome message:
def displayWelcome(): print("Welcome!")# Function calldisplayWelcome() # Output: Welcome!
Non-value-returning function calls are used as statements. They perform an action but do not return a value that can be used in an expression.
displayWelcome()
No Return Value:
Since these functions do not return a value, it does not make sense to assign the result of the function call to a variable:
welcome_displayed = displayWelcome() # This does not serve any purpose.
Functions with No Arguments:
Similar to value-returning functions, non-value-returning functions can also be designed to take no arguments. Parentheses are still included in the function call to indicate that the identifier is a function name and not a variable.
def sayHello():
print("Hello!")sayHello() # Output: Hello!