Python Built-in Functions in hindi ?

Python Built-in Functions

Built-in Functions ऐसे फंक्शन होते है जो पहले से pre-defined होते है । python 3.6 मे 68 Built-in Functions  है ।

abs ( ) function

Python मे  abs ( )  फंक्शन  एक argument लेता है और  absolute value को return करता है । Argument एक integer number या floating number हो सकता है । यदि argument मे complex number हो तो abs () function , magnitude.को return करता है ।

Example :-

integer = -500
print('Absolute value of -500 is:', abs(integer))

floating = -220.83
print('Absolute value of -220.83 is:', abs(floating))

Output :- 
Absolute value of -500 is: 500
Absolute value of -220.83 is: 220.83

all( ) function

पाइथन all ( ) फंक्शन iterable object (जैसे list, dictionary, आदि ।) को accepts करती है । यह true और false वैल्यू return करती है । यदि iterable object खाली है, तो abs () फ़ंक्शन true return करेगा ।

  • Returns true when all elements in iterable is true otherwise return false.

Example :- 

# all true values 
k = [ 3, 4, 6, 7, 8]
print(all(k))

# all values false
k = [1, False]
print(all(k))

k = [1, 3, 7, 0]
print(all(k))

k = [1, False, 7]
print(all(k))

# empty iterable
k = []
print(all(k))

Output :-
True
False
False
False
True

any ( ) function

Checks if any Element of an Iterable is True otherwise return false.

Example :- 

x = [7, 5, 2, 0]
print(any(x))

x = [0, False]
print(any(x))

x = [0, False, 7]
print(any(x))

x = []
print(any(x))

Output:- 
True
False
True
False

ancii ( ) function

Returns String Containing Printable Representation.

Example :- 

normalText = 'pthon is very easy and simple language.'
print(ascii(normalText))

otherText = 'pthön is very easy and simple language.'
print(ascii(otherText))

print('Pyth\xf6 is very easy and simple language.')

Output :- 

'pthon is very easy and simple language.'
'pth\xf6n is very easy and simple language.'
Pythö is very easy and simple language.

bool ( ) function

Python bool ( ) फंक्शन value को बूलियन (true or false) मे converts करता है ।

Example :

t1 = []
print(t1,'is',bool(1))
t2 = [0]
print(t2,'is',bool(t2))
t3 = 0.0
print(t3,'is',bool(t3))
t4 = 'hello'
print(t4,'is',bool(t4)) 

Output :- 
[] is True
[0] is True
0.0 is False
hello is True

bin () function

पाइथन मे bin () फंक्शन का उपयोग करके हम किसी integer number को binary number मे convert करते है। और result के start मे prefix 0b के साथ हमे पूरा रिजल्ट मिलता है ।

Example :- 

x =  20
y =  bin(x)
print (y)

Output :- 
0b10100

bytes ( ) function

पाइथन bytes () फंक्शन bytes object return करता है । ये bytearray() function का immutable version है ।

syntax :-

bytes(source, encoding, errors)

Example :- 

string = "welcome thetechnicalnotes.com"
arr = bytes(string, 'utf-8')
print(arr)  

Output :- 
b'welcome thetechnicalnotes.com'

bytearray ( ) function

पाइथन bytearray () फंक्शन bytearray object return करता है ।

Example :- 

# example 1:- 
string = "Python is a programming language."
# string with encoding 'utf-8'
arr = bytearray(string, 'utf-8')
print(arr)

Output :-
bytearray(b'Python is a programming language.')
# example 2:- 
string = "Python is a programming language."
# string with encoding 'utf-8'
arr = bytearray(string, 'utf-8')
size = 5
arr = bytearray(size)
print(arr)
Output :-
bytearray(b'\x00\x00\x00\x00\x00')