pub-3785248829033902 | Python: Defining a Function and Add+ | - Big data with Python

| Python: Defining a Function and Add+ |

Defining a Function

You can define functions to provide the required functionality. Here are simple rules to define a function in Python. Function blocks begin with the keyword def followed by the function name and parentheses def ( ). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.

The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None. 


The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of statement for addition of 10 + 5 in Python:

Æ’ python command

def t(a, b):
    c = a + b
    return c
print(t(10, 5))

output

15   


Previous
Next Post »