python built in functions- advanced programming in java

jessaint 11 views 6 slides Mar 02, 2025
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

python built in functions


Slide Content

Unit 1

Function Description delattr() Deletes the 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 )

Function Description dict() Returns a 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

Function Description dir() Returns a 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', 'country', 'name']

Function Description divmod() Returns the 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)

Function Description enumerate() Takes a collection (e.g. a tuple) and returns it as an enumerate object Python Built in Functions Example: Convert a tuple into an enumerate object
Tags