PYTHON BASICSChapter 1 · Python Basics
Numbers and math
Python has two everyday number types: int for whole numbers and float for numbers with a decimal point. The operators +, -, * and / work like a calculator, // divides and drops the remainder, % gives the remainder, and ** raises to a power.
Worked example
How it reads
/always gives a float, so17 / 5is 3.4//keeps only the whole part (3) and%gives what is left over (2)round(x, 2)rounds to two decimal places
Common mistakes
/always returns a float, even for10 / 2(that is5.0, not5).^is not a power in Python. Use**:2 ** 3is 8.

Cloud tip:
n % 2 == 0 tests whether a number is even. It is one of the most used tricks in programming.

