Blog

Types of Function in python in hindi - Bharosewale.com

Posted By Naveen Singh on 24 May 2023

python-program
types-of-functions-in-python-in-hindi

 

Python में function कितने प्रकार के होते है?( How many types of functions in python?)

 

Python में functions basically दो प्रकार के होते हैं-

i) Built-in function

ii) User defined function

 

Built-in function in python-:

 

python में built-in function को predefined function भी कहते हैं जो की पहले से बने हुए होते है जिनका उपयोग हम उन functions को call करा कर करते है। Python में कई प्रकार के built-in

functions होते है।

 

abs()-:  यह function किसी number की absolute value को return करता है।

Example-:

num = abs(-3.5)

Output-:

3.5

 

all() -: अगर iterable object के सारे items true होते हैं तब यह function true

value return करता है।

Example-:

iter = [1,2,3]

a = all(iter)

print(a)

Output-:

True

 

any-: अगर iterable object में कोई एक item भी true होता है तब यह

function true value return करता है।

Example-:

list1 = [0,5,6]

a = any(list1)

print(a)

Output-:

True

 

max() - : यह function किसी iterable में से largest value को return करता

 है।

Example-:

print(max(2,5))

Output-:

5

 

min()-: यह function किसी iterable में से lowest value को return करता

 है।

Example-:

print(min(2,5))

Output-:

2       


User defined function in python-:

 

Python में user defined function वह function होते हैं जो user खुद से create करता है। यह basically दो प्रकार के होते हैं -

 

a) Return type function

b) Non-return type function

 

a) Return type function-:

Return type function वो function होते हैं जो किसी प्रकार की value को return करते है। मतलब इस function का प्रयोग हम value return करने के लिए करते हैं।

 

Example-:

def my_function(a,b):

   return a+b

a = int(input("Enter first number:"))

b = int(input("Enter second number:"))

result = my_function(a,b)

print("Sum of two numbers:",result)

 

Output-:

Enter first number:4

Enter second number:6

Sum of two numbers: 10

 

b) Non-return type function -:

 

Non-return type function वो function होते हैं जो किसी प्रकार की value return नही करते है।

Example-:

def my_function():

   print("This function not return any type of value")

my_function()

 

Output-:

This function not return any type of value


 

Comments