1f = 11
2print(f)
3del f
4print(f) # This should show a error thing that says that this variable doesn't exist
1OK, 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
1def myFunction(say): #you can add variables to the function
2 print(say)
3
4myFunction("Hello")
5
6age = input("How old are you?")
7
8myFunction("You are {} years old!".format(age))
9
10#this is what you get:
11
12Hello
13How old are you?
14>>11 #lol my real age actually
15You are 11 years old!
1def example(): #This defines it
2 print("Example.") #This is the defined commands
3
4example() #And this is the commands being run
1def test_function(argument1,argument2,argument3) :
2 # Do something with the code, and the arguments.
3 print(argument1)
4 print(argument2)
5 print(argument3)
6
7# Calling the function.
8
9test_function('Hello','World','!')
10
11# Output
12'''
13Hello
14World
15!
16'''
1# We use the def keyword to write a function in python
2# Format: def function_name():
3# For example:
4def Bark():
5 print("Bark! Bark!")
6
7# If we want to run the function
8Bark()