Search⌘ K
AI Features

Built-in Functions and Modules

Explore Python's built-in functions available throughout your code and discover essential modules like math, cmath, random, and decimal. Learn how to import and use these modules to perform advanced mathematical operations and random number generation, enhancing your programming skills.

We'll cover the following...

Built-in functions

Python has many built-in functions that are always available in any part of the program. The print() function that we use to send output to the screen is a built-in function.

Help for any built-in function is available using help(function).

Built-in functions that are commonly used with numbers are:

abs(x) # returns absolute value of x
pow(x, y) # returns value of x raised to y
min(x1, x2,...)# returns smallest argument
max(x1, x2,...)# returns largest argument
divmod(x, y) # returns a pair(x // y,x % y)
round(x [,n]) # returns x rounded to n digits after .
bin(x) # returns binary equivalent of x
oct(x) # returns octal equivalent of x
hex(x) # returns hexadecimal equivalent of x
Commonly used built-in functions

The following Python program shows how to use ...