Sunday, May 24, 2020

Build-in function in python programming



learn about all the built-in functions in python and learn about their syntax and how to use them.

Build-in function in python programming
Build-in function in python programming

abs function in python:-

abs() function is also known as python absolute value function it's used to return the absolute value of the specified number.

Syntax : -

abs(n) 

all() function in python :-

abs() function in python return true if all elements of the iterable are true otherwise it return false.
 
all(iterable) 

any() function in python :-

any() function in python return true if all elements of the iterable are true If the iterable is empty, return False.

any(iterable) 

ascii() function in python :-

ASCII() function in python return a readable format of any object (Strings, Tuples, Lists, etc). It also replaces any non-ASCII characters with escape characters.

Syntax : - 

ascii(object) 

bin() function in python :-

bin() function in python programming is used to change any specified number into binary form and return that binary number to the calling function.

Syntax : - 

bin(n)

remember result will start with 0b prefix.

bool() function in python :-

bin() function in python programming return the boolean value of specified objects in the python program.
If the object is not true then it will be : - 

The object is empty, like [], (), {}
The object is False
The object is 0
The object is None


Syntax : - 

bool(object)

bytearray() function in python :-

bytearray() function in python programming uses to return the byte of object. It can convert objects into bytearray objects.

Syntax : -

bytearray(x, encoding, error)

X : - it is a source to create the bytearray().

Encoding: -  encode the string


Error:- Specified what to if any error occurs.


byte() function in python :-

 byte() function in python programming return a byte object and convert the object into byte object same as bytearray() function the only difference between byte and bytearray() function is that byte return an object that can not be modified and bytearray() function return an object that can be modified.

Syntax : - 

bytes(x, encoding, error)

byte() function in python :-

byte() function in python programming returns true if the specified object is callable or return false.

Syntax : - 

callable(object) 

chr() function in python programming:-

chr() function in python returns the character which is represented by the help of Unicode.

Syntax : - 

chr(number) 


compile() function in python :-

compile() function in python return the source as the code object which is ready to be executed or run.

Syntax : - 

compile(source,
    filename, mode, flag, dont_inherit, 
    optimize)
   

complex() function in python :-

the complex() function given a complex number that contains a real number and an imaginary number.

Syntax : -

complex(real, imaginary) 


delattr() function in python :-

delattr() function help you to delete the specified attribute from the specified object.

Syntax : -

delattr(object, attribute)
  

dict() function in python :-

dict() function help you to create the dictionary in python.

Syntax : -

delattr(object, attribute)
  
dict() doesn't return anything.


dir() function in python :-


dir() function in python returns the properties and methods of the specified object, without the values. it means dir() function will tell you what process should apply on the object.

Syntax : -

dir(object)
  
  
divmod() function in python :-

 

divmod() function in python

is used to return the
quotient and the remainder because argument1 (dividend) is divided by argument2 (divisor).

Syntax : -

divmod(divident, divisor)
   
 

enumerate() function in python :-

 enumerate() function in python takes a list of tuples and return it as an enumerate object.Its also used to add a counter to an iterable and give back in a form of enumerate object.

Syntax : -

enumerate(iterable, start)
 

eval

() function in python :-

eval() function in python use to validate the specified expression if the expression is legal Python statement, then it go further execution.

Syntax : -

eval(expression, globals, locals)
 

exec() function in python :-

 exec() function work as same as eval() function but only different is exec() execute a large blocks of code unlike the eval() function in python execute the single expression.

Syntax : -

exec(object, globals, locals)


filter() function in python :-

filter() function in python use to filters the given iterable(set which is going to be filter like list, tuples etc.) with the help of a function which test the every element in given iterable to be true or not.

Syntax : -

filter(function, iterable)
  

float() function :-

filter() function in python converts the given value into a floating point.

Syntax : -

float(value)


format() function :-

format() function in python given value into a specified format.

Syntax : -

format(value, 
    format)


froaenset() function for python :-

frozenset() function in python gives an unchangeable frozenset object which can be define by user.

Syntax : -

frozenset(iterable).
  

getattr() function for python :-

getattr() function in python gives the specified attribute from the specified object in python.

Syntax : -

getattr(object, attribute, default)
  

globals() function for python :-

globals() function in python programming gives a table of the symbol as a dictionary and that symbol table contains necessary information about the current program.

Syntax : -

globals()


hasattr() function for python :-

hasattr() will return true if the specified object in python gives the specified attribute otherwise gives false.

Syntax : -

hasattr(object, attribute)
  

hex() function for python :-

hex() function in python programming uses to convert the specified number into a hexadecimal number. 

Syntax : - 
hex(number)
  

id() function :-

id() function in python gives the unique id for a specified object and id is assigned to object at a time when the object is created.
Well id is a memory address for that specified object and it will be changed every time user run the python program

Syntax : -

id(object)

input() function

input() function in python use to give input to the python program.


Syntax : -

input(prompt)
  
 

int() function

int() function help to convert the specified number into an integer number.

Syntax : -

int(value, base)
python isinstance() function :-

isinstance() function gives true if the specified object is followed by the specified type otherwise false.


Syntax : -

isinstance(object, type)
 

python issubclass() function :-

issubclass() function gives true if the specified object is a subclass of a class object otherwise false.

Syntax : -

issubclass(object, subclass

subclass: - A class of objects.

python iter() function :-


Return the iterator object in python.

Syntax : -

iter(object, sentinel)


python len() function :-

len() function is very helpful to know about the number of items in an object.

Syntax : -

len(object)

python list() function :-

this function does the same as its name says list() function in python use to create an ordered and changeable list of objects.

Syntax : -

list(iterable)
  

python local() function:-

local() function in python returns a symbol table which contains all the necessary information about the python program. 

Syntax : -

locals()
   

map() function

map() function in python is a special function it executes the specified function for every item in iterable. The item is sent to the function as a parameter.

Syntax : -

map(function, iterables)
   

max() function:-

As its name says max() function gives the maximum value item from iterable.

Syntax : -

max(iterable)

memoryview () function:-

 memoryview() object gives a memory view object from a specified object.

Syntax : -

memoryview(obj

min() function:-

As its name says min() function gives the minimum value item within the given iterable.

Syntax : -

min(iterable)

next() function:-

As its name says next() function returns the next value form the given an iterator. Add a default value for the end of the iterable.

Syntax : -

next(iterable, default)

object() function:-


object function in python programming gives you a new object that object can't be changed or update with new properties  because it contains  built-in properties and methods that are default and for all classes.

Syntax : -

object()

oct() function in python:-


oct function in python programming helps to convert an integer into an octal string.

Syntax : -

oct(int)

open() function in python:-


open() function in python use to open a file and returns the file objects.

Syntax : -

open(file,mode)

ord() function in python:-

ord() function in python gives the number in Unicode which is used to representing the specified character. 

Syntax : -

ord(character)

pow() function in python:-

As its name says pow() function returns the value of x to the power of y (xy).if any third parameter is present then it takes as modulus in python.

Syntax : -

pow(x, y, z)

print() function in python:-

print() function is used to print the specified message to the screen and other output devices. The message can be any object.

Syntax : -

print(object(s), sep=separator, end=end, file=file, flush=flush)

range() function in python:-

range() function return the sequence of number which is started by default 0 and increase by 1 and stops before a specified number.

Syntax : -

range(start, stop, step)

reversed() function in python:-

reversed () function in python gives the reverse iteration object in python.

Syntax : -

reversed(sequence)

round() function in python:-

the round() function gives a floating-point number and that number is a rounded version of a specified number in python program. It means it gives the nearest integer number.

Syntax : -

round(number,digits)

set() function in python:-

the set() function used to create a set of objects and the item list in the set is unordered and it will appear in random order.

Syntax : -

set(iterable)

setattr() function in python:-

setattr() function in python programming set the specified attribute for the specified object.

Syntax : -

setattr(object, attribute, value)
  

slice() function in python:-

slice() function in python is used to slice a specified sequence and starting point and endpoint of slicing can also be specified. You can also specify the steps for the slicing process.

Syntax : -

slice(start, end, step)
  

sorted() function in python:-

sorted() function use for data structure in python this function used to sort the list of the specified iterable object. You can also define the ascending or descending order.

Syntax : -

sorted(iterable, key=key, reverse=reverse)  

str() function in python:-

str() function used to convert the specified value into a string.

Syntax : -

str(object, encoding=encoding, errors=errors)  

sum() function in python:-

sum() function returns the number which is the sum of all iterable in python.

Syntax : -

sum(iterable,  start)

super() function in python:-

  super() function in python is used to give access to all the properties and methods of parent and sibling classes.

Syntax : -

super()

tuple() function in python:-

tuple() function is used to creates the tuple object in python. 

Syntax : -

tuple(iterable)
  

type() function in python:- 

it will work as its name says type function in python programming helps to tell about the type of specified object.

Syntax : -

type(object, bases, dict)
  

vars() function in python:- 


vars() function is used to return the __dic__ attribute of an object.

__dic__ attribute containing the object's changeable attributes.

Syntax : -

vars(object)
  

zip() function in python:- 

zip() function in python will work like a zip file which means zip() in python return a zip() object which is a tuple of iterator so the first item in peach passed iterator is paired together, and the next one will do the same process.

if the passed iterator has a different length then the last item from the iterator decides the length of the new iterator.

Syntax : -

zip(iterator1, iterator2, iterator3 ...)
  
  
 these all are the Python Built-in Functions which used in python programs.

0 comments:

Post a Comment