0% found this document useful (0 votes)
8 views3 pages

Built-In Functions

Python provides a variety of built-in functions that simplify coding by performing common tasks without the need for module imports. These functions are categorized into areas such as mathematical operations, type conversion, iteration, and object manipulation, with frequently used examples including print(), len(), and type(). Overall, they enhance the efficiency and ease of programming in Python.

Uploaded by

Amandeep kaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Built-In Functions

Python provides a variety of built-in functions that simplify coding by performing common tasks without the need for module imports. These functions are categorized into areas such as mathematical operations, type conversion, iteration, and object manipulation, with frequently used examples including print(), len(), and type(). Overall, they enhance the efficiency and ease of programming in Python.

Uploaded by

Amandeep kaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

3.

Built-in functions
Python has a rich set of built-in functions that are available for use at any time
in the interpreter, without needing to import any modules. These functions
perform default, common tasks and help ease the writing of code.
Commonly used built-in functions include:
 Numeric & Boolean: abs() (absolute value), bool() (type
conversion), float() (convert to float), int() (convert to int), round() (round
to decimals).
 Sequences & Collections: len() (object
length), list(), set(), tuple(), dict() (create objects), range() (sequence of
numbers), sorted() (sort iterables).
 Iterables: all(), any(), map(), zip().
 Input/Output & Utility: print() (output), open() (file
handling), dir() (object properties), type() (object
type), format() (formatting), chr() (Unicode).
 Mathematical: max(), min(), sum()
Common Built-in Functions
Some of the most frequently used built-in functions are:
 print(): Prints the given object(s) to the standard output device.
 len(): Returns the length of an object (e.g., a string, list, or
tuple).
 type(): Returns the type of the object.
 int(), float(), str(), bool(): Convert values to integer, floating
point, string, or boolean types, respectively.
 input(): Allows user input from the console.
 max(), min(): Returns the largest or smallest item in an iterable.
 sum(): Sums the items of an iterable.
 open(): Opens a file and returns a file object.
 help(): Invokes the built-in help system to provide
documentation on an object.

Categories of Built-in Functions


Python's built-in functions can be categorized based on their purpose:
 Mathematical Operations:
o abs(): Returns the absolute value of a number.
o divmod(): Returns the quotient and remainder as a tuple
when dividing two numbers.
o pow(): Returns the value of x to the power of y.
o round(): Rounds a number to a specified number of
decimals.
 Type Conversion and Creation:
o list(), dict(), tuple(), set(): Create respective collection
objects from iterables.
o bin(), hex(), oct(): Convert an integer to its binary,
hexadecimal, or octal string representation.
o chr(), ord(): Convert between Unicode code points
(integers) and characters.
 Iteration and Filtering:
o range(): Returns a sequence of numbers.
o enumerate(): Adds a counter to an iterable and returns it as
an enumerate object.
o filter(), map(): Construct iterators by filtering elements or
applying a function to each item, respectively.
o sorted(), reversed(): Return a new sorted list or a reversed
iterator of a sequence.
o zip(): Returns an iterator that aggregates elements from
multiple iterables.
 Object and Attribute Manipulation:
o dir(): Attempts to return a list of valid attributes and
methods for an object.
o getattr(), setattr(), hasattr(), delattr(): Get, set, check for, or
delete attributes of an object.
o isinstance(), issubclass(): Check the type or inheritance
relationship of objects and classes.

You might also like