Python Built-In Functions And Module
Table of Contents
Python is a interpreter computer programming language. It has number of built in function, module and types that are always available. Your can use any time. Some of built it function we have already use in previous chapter for example print, input, int, string, float and decimal.
Python built-in functions list are follow.
Python Built-In Functions
You can get above built-In Functions from python IDE. Follow these step to get the list.
Step 01: Open python IDE by click on start menu and search python IDE click on this.
Step 02: Type dire(__builtins__) and press the enter.
Python Built-in Function List:
`Here we discuss only some important built-in function one by on which are using in python programming. These are follow:-
Python Print() Function:
Print function are use to get the value which store in variable. Print syntax are follow:-
example-01 :
print (“hello gss technology”)
example 02:
>>>a=(1,2,3,4,5)
>>print (a)
>>1,2,3,4,5
String:
A string is a sequence of characters.
A character is simply a symbol. For example, the English language has 26 characters.
Computer do not deal with characters, they deal with number (binary). Even though you may see characters on your screen, internally it is stored and manipulated as a combination of Os and ls.
Example:
>>>Str =(“programmer”)
>>>print(“Str =”, Str)
How to Access Character In a String:
We can access individual character from string using indexing and range of character using slicing.
The index starts from 0. Trying to access a character which is out of index range will raise IndexError.
The index value must be the integer. We can’t use decimal and float or other types, this will result into TypeError.
Python allow the negative index. The index of [-1] refer the last item, [-2] the 2nd last item and so on. We can access a range of items in a string by using the slicing operator [:] which called colon.
Example:
>>>Str=”programming”
>>Print(Str)
>>Print(“index 0 is: ”, Str[0])
>>print(“index1 is:”, Str[1])
>>print(“index 2 is:”, Str[3])
print(“index 3 is:”, Str[4])
>>print(“index 4 to 7 is:”, Str[4:7])
>>>print(“index 5 to 9 is:”, Str[5:9])
The out put is:
index0 is: p
index1 is: r
index2 is: g
index3 is: r
Range index 4 to 7 is: ram
index 5 to 9 is: amme
Python abs() Function:
In python the abs() function return the absolute value of the giver number. If the number a array is have the positive and negative value, abs() returns is magnitude.
Example of abs() function:
>>>integer =10
>>>print(‘absolute value of 10 is:’, abs(intger))
The output is:absolute value of 10 is:-10
Python abs() Decimal Function:
Python char() Function:
In python char () function use to return the character (string ) from integer represent the unicode code pint of the character. In a programming a all character and sign have a unique number. We can get the specific character by using char () function.
The syntax of char () is:
char (i)
Parameter of char () Function:
char () method take a single parameter from an integer (i).
The valid range of char () function is from 0 to 1114111.
If the integer (i) is ou tof range then ValueError will be display.
Example :
>>print(chr(97))
a
>>print(chr(90))
z
>>print(chr(91))
[
>>print(chr(1201))
>>ұ
Python bin () Function:
In Python bin () Function is use to get the binary code and convert it string equivalent of a given integer. The parameter is not an integer.
The syntax of bin is bin ()
bin(number)
Example:
>>>bin (15)
Output is : ‘0b1111’
bin (5)
Output is : ‘0b101’
Python input () Method:
In python the input () method read the line from input, it convert into a string and return. You can use it when you want to get some required information from the user. Here the use is bound to input required information.
The syntax of input is
>input (‘Enter Your Name :’)
Example :
>>input (‘Enter Your Name :’)
Enter Your Name :SHARAFAT HUSSAIN
>>> input (‘Enter Your Age :’)
Enter Your Age :30
’30’
>>>
Python len () Function:
In python the len () function use return the length of any string.
Example Of len ():
>>>>> len (‘gsstech’)
7
>>> name = ‘gsstech’
>>> print (“The length of ‘gsstech’ is : “, len(name))
The length of ‘gsstech’ is : 7
>>>
Summary Of Pythons Built-in Function:
Python built-in functions easy to understand for the beginner. These built-in functions save the time of developer and get the better result. To use these python built-in functions there are no more coding required in a specific class or module.
Useful Links:
Pingback: How To Create Function In Python? - GSS TECHNOLOGY
When I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I get 4 emails with the exact same comment. Is there a way you are able to remove me from that service? Appreciate it! Samantha Orrin Laurena
Pingback: Free PHP MySQL POS With Source Code 2021 | GSS TECHNOLOGY