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!
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 example(): #This defines it
2 print("Example.") #This is the defined commands
3
4example() #And this is the commands being run
1def firstProgram(x):
2 print(x)
3
4firstProgram("Hello, World!")
5# Prints "Hello, World!"
1def FunctionName(Parameters):
2 # Function Content
3FunctionName() #Calling Function