Friday, January 10, 2014

Basic part-5 | Functions

 Hello ...Friends , Today we are going to discus about the functions in the python. Actually a function is a block of code which is well organised ,reusable code that is used to perform a single, related action. any function provides better molecularity for your application and a high degree of code reusing.

as we know in other programming there are various built in functions like print () , main () ... etc. so the python too  having various built in function but we can define our functions in the python & in this tut we are going to discus how to define a function & how to call a function in python etc. So let's start

we can define function as :

def function ( arg1, arg2 .... )
      -...
      -...
      -...
      - return value
So from here we can see any function in python can be defined by using def & then function_name with argument in it.So let's make a simple program to understand a function in python

let's make it more easy to understand & adding previous coding snippet in the function


now let's run this code & get the output here


So if we talk about predefined functions in python then we can see like range () , raw_input() vars () , hash () , filter () etc are the built in or predefined functions in the python.

Exercise :
1. Try to make a program with your self defined functions. & try to call them at anywhere in your codes.
2. Try to work with build in functions in your code.

Enjoy coding in simple way with me :')

No comments:

Post a Comment