mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
python integer division vs float division
This commit is contained in:
1 parent
2ae33ca1db
commit
a69b2145a7
1 file changed
+8
-6
@@ -127,13 +127,15 @@ See: [File Handling](#file-handling-2)
|
||||
|
||||
### Arithmetic
|
||||
```python
|
||||
result = 10 + 30 # => 40
|
||||
result = 40 - 10 # => 30
|
||||
result = 50 * 5 # => 250
|
||||
result = 16 / 4 # => 4
|
||||
result = 25 % 2 # => 1
|
||||
result = 5 ** 3 # => 125
|
||||
result = 10 + 30 # => 40
|
||||
result = 40 - 10 # => 30
|
||||
result = 50 * 5 # => 250
|
||||
result = 16 / 4 # => 4.0 (Float Division)
|
||||
result = 16 // 4 # => 4 (Integer Division)
|
||||
result = 25 % 2 # => 1
|
||||
result = 5 ** 3 # => 125
|
||||
```
|
||||
The `/` means quotient of x and y, and the `//` means floored quotient of x and y, also see [StackOverflow](https://stackoverflow.com/a/183870/13192320)
|
||||
|
||||
### Plus-Equals
|
||||
```python
|
||||
|
||||
Reference in new issue
Block a user