The round function

The round function takes a float and an integer as its arguments. The second value defines the desired number of digits after the decimal point. This second value is optional—if nothing is passed, the function will return an integer as a result. The following is an example for the round function:

>>> round(3.14159265359, 2)
3.14

>>> round(3.14159265359)
3

In accordance with standard procedure, the function rounds the values up if the next digit is equal to 5 or above; otherwise, it rounds it down.

The following section is focused on functions that work with iterables—collections composed of multiple values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset