def python code example
Example 1: python functions
def myFunction(say):
print(say)
myFunction("Hello")
age = input("How old are you?")
myFunction("You are {} years old!".format(age))
Hello
How old are you?
>>11
You are 11 years old!
Example 2: how to define function in python
def example():
print("Example.")
example()
Example 3: create function in python
def myFunction():
print('I am running in a function!')
Example 4: python function
def my_function():
print("Hello from a function")
my_function()
Example 5: python def
def foo():
print("Hello")
foo()
def add(numA, numB):
print(numA+numB)
return numA+numB
num = add(1, 5)
print(num)
Example 6: def function in python
OK, basically def function() is a block where you will have one task that you can repeat all over again in the code to make it look short and clean