Knowledge organisersSubprograms
Return a value to program.
A function is a subprogram that calculates and returns a value using the return keyword. The returned value can be stored in a variable or used in an expression.
return to send a value backresult = my_function() stores the returned valueint, str, bool, listreturn is reacheddef calculate_area(width, height):
return width * height
area = calculate_area(5, 3)
print("Area: " + str(area)) # Area: 15