Functions That Python Provides

Python comes with many built-in functions that perform common operations. One example is abs, which produces the absolute value of a number:

 >>>​​ ​​abs(-9)
 9
 >>>​​ ​​abs(3.3)
 3.3

Each of these statements is a function call.

The general form of a function call is as follows:

 function_name(arguments)

An argument is an expression that appears between the parentheses of a function call. In abs(-9), the argument is -9.

Here, we calculate the difference between a day temperature and a night temperature, as might ...

Get Practical Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.