Python – Defining Functions

The def keyword introduces a function and must be followed by a function name and parenthesized list of formal parameters. In some scenarios the parameters may be empty and in other they may be defined. The statement definition inside of the function must be indented.  Python is different from other languages in that even without a return statement it still returns a value.


def testFunction ():

newInput = input("Input something: ")

print("Your input is: ", newInput)

The return value returns with a value from a function. Return without an expression argument returns None.


**This article is written for Python 3.6

<< Control Flow Statements

Exception Handling >>

%d bloggers like this: