Function Description
delattr() Deletesthe specified attribute
(property or method) from the
specified object
Python Built in Functions
class Person:
name = "John"
age = 36
country = "Norway"
delattr(Person, 'age')
# The Person object will no longer contain an "age" property
Syntax:
delattr(object, attribute)
3.
Function Description
dict() Returnsa dictionary (Array)
Python Built in Functions
The dict() function creates a dictionary.
Example: Create a dictionary containing personal information:
x = dict(name = "John", age = 36, country = "Norway")
print(x)
{'name': 'John', 'age': 36, 'country':
'Norway'}
output
4.
Function Description
dir() Returnsa list of the specified object's properties and methods
Python Built in Functions
Syntax : dir(object)
Example: Create a dictionary containing personal information:
class Person:
name = "John"
age = 36
country = "Norway"
print(dir(Person))
output
['__class__', '__delattr__', '__dict__',
'__dir__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__',
'__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__',
'__module__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__', 'age',
5.
Function Description
divmod() Returnsthe quotient and the remainder when argument1 is
divided by argument2
Python Built in Functions
Example Display the quotient and the remainder of 5 divided by 2:
x = divmod(5, 2)
output
x = divmod(5, 2)
print(x) (2, 1)
6.
Function Description
enumerate() Takesa collection (e.g. a tuple) and returns it as an enumerate
object
Python Built in Functions
Example: Convert a tuple into an enumerate object