August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 18 | Round and Round We Go |
| | print(round(1.5), round(2.5)) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: 2 2
Rounding seems easy. round(1.1) evaluates to 1. round(1.8) evaluates to 2. The question is, how do you round the .5 numbers? Should you round up? Down? Turns out, there are a lot of ways to do it.
Python 3 uses bankers’ rounding. Odd numbers are rounded up; even numbers ...
Read now
Unlock full access