All courses › Programming with Python › Numbers and types
Numbers and types
Python has several kinds of numbers. int is a whole number, float a decimal number. Regular division / always gives a float, while // rounds down to an integer and % gives the remainder. type(x) shows a value's type.
regular division, always float
integer division, rounded down
remainder after integer division
Symbols
| the numbers being divided |
Example
7 // 2 gives 3, and 7 % 2 gives 1, since .
7 / 2 gives 3.5.
// and % are linked: a == (a // b) * b + a % b.