PYTHON BUILD-IN FUNCTIONS

LEN()

Len function take an iterable object and returns the numbers of items in an object.

Example:

>>items = [1,2,3,4]

>>print(len(items)) Output :4

ZIP()

Zip function can take nth iterable objects and return a zip object which is an iterator of tuples.

Example:

>>ids=[1,2,3]

>>names=[‘a’,’b’,’c’]

zipobj=zip(ids,names)

print(list(z)) Output: [(1,’a’),(2,’b’)'(3,’c’)]

ORD()

Ord function return a number that represent the unicode of a specified character.

Example:

>>num=ord(‘A’)

>>print(num) Output: 65

ISINSTANCE()

Isinstance function take two arguments

  • Object
  • Object’s class name

Returns True if a specified object is an instance of a specified object.

Example:

>>num=[1,2,3]

>>print(isinstance(num,int)) Output: True

DIVMOD()

This function take two arguments

  • divident
  • divisor

It’s return the quotient and the remainder.

Example:

>>print(divmod(2,4)) Output: (2,0)

DIR()

Dir function return all properties and methods of the specified object.

Example:

>>string=”python”

>>print(dir(string)) Output: [‘find’,’format‘,‘format_map’…..]

CHR()

Chr function take integer number and returns a character from the specified unicode code.

Example:

>>print(chr(‘A’)) Output: 65

1 thought on “PYTHON BUILD-IN FUNCTIONS

  1. Dhayanithi Thangaraju's avatarDhayanithi Thangaraju

    Hello Janani, I was going through your python related articles and your really doing good, Continue to rock.

    Liked by 1 person

Leave a comment

Design a site like this with WordPress.com
Get started