python function | Function in python with examples in hindi

Function In Python – python Function ko ham isliye istemal karte hai taki hame ek hi code ko bar bar likhna na pade isliye python language me ham function ko banante hai |

Python Function

Function Kiya Hai ? :- Function Line of code ya sub program hota hai inka ek group hota hai chota program ka us program me kitni bhi line ho sakti hai or inka aapna ek name & Features hota Hai Or Function ko Aap Program me Kahi bhi Call Ya Dobara Istemal kar Sakte Hai |

Function ko Kyo Istemal Karte hai ? :- Jab Ham koi code likhte hai to wo code main ke under hi execute hota hai | Lekin Jab koi program bahut Bada Ho Jaye Or koi code of line bar bar repeat ho rhi ho to ham function Bana Sakte hai isse program aashan ho jata hai |

Types of Function In Python

Function Mainly 2 Tarah ke hote hai |

  1. Built In Function
  2. User Defined Function
Built In Function 
len()
str()
etc
function in python with examples in hindi

Defining Functions

def fucntion_name(arguments):
  • Def :- Jab ham User defined function banate hai to hame Def Function ka istemal karna padta hai |
  • Function Name :- Jab Ham User Defined Function Banate hai To ham function ka name dete hai & uska name ham kuch bhi de sakte hai |
  • Parameter List ( Arguments ) :- Parameter List means hota hai ki use kitne inputs diye jayenge suppose agar ham ek 2 number addition ka program banate hai to ham 2 parameter pass karenge |

Example :

def add_two(a,b):

Add to Two Number using function

def add_two(a,b):
    return a+b

g = int(input("Enter The First Number :")
h = int(input("Enter The Second Number :")
c = add_two(g,h)      # function call
print(c)

Output:

Enter The First Number :10
Enter The Second Number :20
30

Function in python in hindi

Example :- Find 2 Max Value Using Function in python

def greater_value(a,b):
      if a > b:
         return a
      else:
         return b


a = greater_value(2,3)
print(f"Greater Value is : {a}")

Output:

Greater value is : 3

Upper Diye gye output dekh kar aap program ko samanjh sakte hai|

Example 2 :- Find 3 Max Value Using Function in python

def greater_value(a, b, c):
    if a > b:
        if a > c:
            return a
        else:
            return c
    else:
        if b > c:
            return b
        else:
            return c


a = greater_value(2, 3, 6)
print(f"Greater Value is : {a}")

Output :

Greater value is : 6

Upper Diye gye output dekh kar aap program ko samanjh sakte hai|

Example :- Find Last Character in name Using Function in python

def last_char(a):
       return a[-1]


b = input("Enter The Name :")
c = last_char(b)
print(f"Last Character is : {c}")

Output:

Enter The Name :Danish
Last Character is : h

Upper Diye gye output dekh kar aap program ko samanjh sakte hai|

Function inside function

Example 2 :- Find 3 Max Value Using Function inside fucntion in python

def greater_value(a, b):
    if a > b:
        return a
    else:
        return b


def inside_greater(a, b, c):
    bigger = greater_value(a,b)
    return greater_value(bigger, c)


d = inside_greater(10,20,3)

print(f"Greater value is : {d}")

Output :

Greater value is : 20

Upper Diye gye output dekh kar aap program ko samanjh sakte hai|

Function Call in Python

  1. Call by Value
  2. Call By Reference

Call By Value :- Call by Value Means Ham Jab function ko call karenge to usko value supply krenge ya fir variable ka name supply karenge means waha par jo value hogi wo actual argument se copy ho kar formal argument me chali jayegi. lekin ye value 2 hogi 1 value jo actual argument ke pass hai or 1 iski value copy jo formal argument ke pass hai|

Call By Reference :- Call By Reference Matlab ye keval address ko hold karta hai |

functions in python with examples

python function

Dosto mujhe ummed hai ki aap function in python with examples in hindi ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Summary
Review Date
Reviewed Item
function in python with examples in hindi
Author Rating
51star1star1star1star1star

Danish Ali

I Am a 1st Sem BCA Student & I have Skills C, C++ ,Python, HTML,CSS, Computer & Advance Hacking & Blogger & YouTuber.

One thought on “python function | Function in python with examples in hindi

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)