PYTHON BUILT IN FUNCTIONS
Abs()-Returns the absolute value of a number
For Example, x = abs(-7.25)
All()-Returns True if all items in an iterable object are
true
For Example, mylist = [True, True, True]
x = all(mylist)
Bin()-Returns the binary version of a number
For Example, x = bin(36)
Bool()-Returns the boolean value of the specified
object
For Example, x = bool(1)
Compile()-Returns the specified source as an
object, ready to be executed
For Example, mytext = 'print(55)'
x = compile('mytext', 'test', 'eval')
exec(x)
Complex()-Returns a complex number
For Example, x = complex(3, 5)
Dict()-Returns a dictionary
For Example, x = dict(name = "John",
age = 36, country = "Norway")
Dir()- Returns a list of the specified object's
properties and methods
For Example, class Person:
name = "John"
age = 36
country = "Norway"
print(dir(Person))
Eval()-Evaluates and executes an expression
For Example, x = 'print(55)‘
eval(x)
Exec()-Executes the specified code (or object)
For Example, x = 'name
="John"nprint(name)'
exec(x)
Filter()-Use a filter function to exclude items in a
iterable object
For Example,
ages = [5, 12, 17, 18, 24, 32]
def myFunc(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x)
Float()- Returns a floating point number
For Example, x = float(3)
Format()-Formats a specified value
For Example, x = format(0.5, '%')
Forzenset()-Returns a frozenset object
For Example, mylist =
['apple', 'banana', 'cherry']
x = frozenset(mylist)
Getattr()-Returns the value of the specified
attribute (property or method)
For Example, class Person:
name = "John"
age = 36
country = "Norway"
x = getattr(Person, 'age')
Globals-Returns the current global symbol table
as a dictionary
For Example, x = globals()
print(x)
Hash()-Returns the hash value of a specified object
Hex()-Converts a number into a hexadecimal value
For Example, x = hex(255)
Id()-Returns the id of an object
For Example, x = ('apple', 'banana', 'cherry')
y = id(x)
Input()-Allowing user input
For Example, print('Enter your name:')
x = input()
print('Hello, ' + x)
Len() – Returns the length of an object
For Example, mylist =
["apple", "banana", "cherry"]
x = len(mylist)
List()-Returns a list
For Example, x
= list(('apple', 'banana', 'cherry'))
Locals()- Returns an updated dictionary of the
current local symbol table
For Example, x = locals()
print(x)
Map()-Returns the specified iterator with the
specified function applied to each item
For Example, def myfunc(n):
return len(n)
x = map(myfunc, ('apple', 'banana', 'cherry'))
Max()-Returns the largest item in an iterable
For Example, x = max(5, 10)
Min()-Returns the smallest item in an iterable
For Example, a = (1, 5, 3, 9)
x = min(a)
Ord()-Convert an integer representing the Unicode
of the specified character
For Example, x = ord("h")
Pow()-Returns the value of x to the power of y
For Example, x = pow(4, 3)
Print()-Prints to the standard output device
For Example, print("Hello World")
Range()-Returns a sequence of numbers, starting
from 0 and increments by 1 (by default)
For Example, x = range(6)
for n in x:
print(n)
Set()-Returns a new set object
For Example, x
= set(('apple', 'banana', 'cherry'))
Sort()-Returns a sorted list
For Example, a =
("a", "b", "c", "d", "e", "f", "g", "h")
x = slice(2)
print(a[x])
Tuple()-Returns a tuple
For Example, x
= tuple(('apple', 'banana', 'cherry'))
GREENS TECHNOLOGYS
Greens Technology is a leading Training and
Placements company in Chennai. We are
known for our practical approach towards
trainings that enable students to gain real-
time exposure on competitive technologies.
Trainings are offered by employees from
MNCs to give a real corporate exposure.

Python built in functions

  • 1.
    PYTHON BUILT INFUNCTIONS Abs()-Returns the absolute value of a number For Example, x = abs(-7.25) All()-Returns True if all items in an iterable object are true For Example, mylist = [True, True, True] x = all(mylist) Bin()-Returns the binary version of a number For Example, x = bin(36) Bool()-Returns the boolean value of the specified object For Example, x = bool(1)
  • 2.
    Compile()-Returns the specifiedsource as an object, ready to be executed For Example, mytext = 'print(55)' x = compile('mytext', 'test', 'eval') exec(x) Complex()-Returns a complex number For Example, x = complex(3, 5) Dict()-Returns a dictionary For Example, x = dict(name = "John", age = 36, country = "Norway")
  • 3.
    Dir()- Returns alist of the specified object's properties and methods For Example, class Person: name = "John" age = 36 country = "Norway" print(dir(Person)) Eval()-Evaluates and executes an expression For Example, x = 'print(55)‘ eval(x)
  • 4.
    Exec()-Executes the specifiedcode (or object) For Example, x = 'name ="John"nprint(name)' exec(x) Filter()-Use a filter function to exclude items in a iterable object For Example, ages = [5, 12, 17, 18, 24, 32] def myFunc(x): if x < 18: return False else: return True
  • 5.
    adults = filter(myFunc,ages) for x in adults: print(x) Float()- Returns a floating point number For Example, x = float(3) Format()-Formats a specified value For Example, x = format(0.5, '%') Forzenset()-Returns a frozenset object For Example, mylist = ['apple', 'banana', 'cherry'] x = frozenset(mylist)
  • 6.
    Getattr()-Returns the valueof the specified attribute (property or method) For Example, class Person: name = "John" age = 36 country = "Norway" x = getattr(Person, 'age') Globals-Returns the current global symbol table as a dictionary For Example, x = globals() print(x)
  • 7.
    Hash()-Returns the hashvalue of a specified object Hex()-Converts a number into a hexadecimal value For Example, x = hex(255) Id()-Returns the id of an object For Example, x = ('apple', 'banana', 'cherry') y = id(x) Input()-Allowing user input For Example, print('Enter your name:') x = input() print('Hello, ' + x)
  • 8.
    Len() – Returnsthe length of an object For Example, mylist = ["apple", "banana", "cherry"] x = len(mylist) List()-Returns a list For Example, x = list(('apple', 'banana', 'cherry')) Locals()- Returns an updated dictionary of the current local symbol table For Example, x = locals() print(x)
  • 9.
    Map()-Returns the specifiediterator with the specified function applied to each item For Example, def myfunc(n): return len(n) x = map(myfunc, ('apple', 'banana', 'cherry')) Max()-Returns the largest item in an iterable For Example, x = max(5, 10) Min()-Returns the smallest item in an iterable For Example, a = (1, 5, 3, 9) x = min(a)
  • 10.
    Ord()-Convert an integerrepresenting the Unicode of the specified character For Example, x = ord("h") Pow()-Returns the value of x to the power of y For Example, x = pow(4, 3) Print()-Prints to the standard output device For Example, print("Hello World") Range()-Returns a sequence of numbers, starting from 0 and increments by 1 (by default) For Example, x = range(6) for n in x: print(n)
  • 11.
    Set()-Returns a newset object For Example, x = set(('apple', 'banana', 'cherry')) Sort()-Returns a sorted list For Example, a = ("a", "b", "c", "d", "e", "f", "g", "h") x = slice(2) print(a[x]) Tuple()-Returns a tuple For Example, x = tuple(('apple', 'banana', 'cherry'))
  • 12.
    GREENS TECHNOLOGYS Greens Technologyis a leading Training and Placements company in Chennai. We are known for our practical approach towards trainings that enable students to gain real- time exposure on competitive technologies. Trainings are offered by employees from MNCs to give a real corporate exposure.