Python Function


Python function are important and mainly used in program to minimize the use of repeated code.

It is a block of code and it gets executed when it is called

Creating python funtion
                      
        def helloworld():
            print("Hello World!")
        helloworld()
                      
Output:  Hello World!
                    

Addition function

                      
        def addition(x,y):
            return x+y
        addition(2,5)
                      
Output: 7

                    

Parameters?

Parameters are passed in the function.

In Multiplication program x and y are parameters passed in the function.

                      
        def multiplication(x,y):
            return x*y
        addition(2,5)
                      
Output: 10