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!
1# first we have to write 'def'
2# then our function name followed by ()
3# and a ':' abd defining block of code
4
5def multiply(): # naming convention could be same as variable for functions
6 product = 10.5 * 4
7 return product
8
9
10product = multiply()
11print(product)
1#Statements with pound sign are comments, just to guide. They wont be executed.
2#Funtion Definition- Must include def
3def my_Function():
4#statements within a function, will be executed when the function is called
5 print("Hello World!")
6#Function Calling
7my_Function()
1def hello():
2 name = str(input("Enter your name: "))
3 if name:
4 print ("Hello " + str(name))
5 else:
6 print("Hello World")
7 return
8
9hello()