Built-in Functions and Modules
Learn about some basic modules and built-in functions.
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 xpow(x, y) # returns value of x raised to ymin(x1, x2,...)# returns smallest argumentmax(x1, x2,...)# returns largest argumentdivmod(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 xoct(x) # returns octal equivalent of xhex(x) # returns hexadecimal equivalent of x
Commonly used built-in functions
The following Python program shows how to ...