Function in python

Function in python

Hello Friends, I am Nirav. And in this tutorial I going to show you Function in Python..
So, Let's get Started



What is function ?

          A function is a block of organized, reusable code that is used to perform a single, related action. Function provide better modularity for your application and a high degree of code reusing. As you already know,Pyhton gives you many built-in function like print(), etc. but you can also create your own function.

What is user define function ?

           It's provide to create your own function in python.

Why we use function ?

          Once a function is defined it can be used over and over again. you can invoke the same function many time in your program which save your work.

How to create function ?

          In python if you want to create a function first start with def  keyword


Function with one parameter

          When you want to pass one parameter on function for use in function than you have to use function with parameter.


Function with two parameter

          When you want to pass two parameter on function for use in function than you have to use function with parameter.



Return from function

          If you use return statement in function than whatever function give return value that value we can use in some other operations. and it's necessary to give return statement in function.



Maximum number function



Arbitrary argument

          some time we do not know in advance the number of argument that will be passed into a function. python allows us to handle this kind of situation throw function call with arbitrary argument.

In the function definition we use an asterisk (*) before the parameter name to denote this kind of argument. Here is an example.

You also visit my you tube video regarding to this Topic

https://youtu.be/2HyAiEfkPXU

Comments

Popular posts from this blog

Loop Control Statement

Boolean Expression and If..else Condition