Skip to content

Commit b396517

Browse files
committed
Fixes for Maha reviews
1 parent dc9ea11 commit b396517

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

‎docs/python-tutorial/chapters/06-operators-pt01.md‎

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ A quick revision of the concepts we have learned so far:
1212
- Built in functions
1313
- String concatenation & interpolation
1414

15-
In this chapter we will be looking at what comparison and arithmetic operations are.
15+
In this chapter, we will be looking at what comparison and arithmetic operations are.
1616

1717
## Comparison Operators
1818

1919
Comparison Operators (also known as Relational Operators) are used to compare values. They work very
20-
similar to how they do in mathematics.
20+
similarly to how they do in mathematics.
2121

2222
There are six comparison operators:
2323

2424
| Operator Symbol | Name |
2525
| ---------------- | ----------------------------- |
26-
| `>` | Greater Than |
27-
| `<` | Less Than |
28-
| `==` | Equal To |
29-
| `!=` | Not Equal To |
30-
| `>=` | Greater Than Or Equal To |
31-
| `<=` | Less Than Or Equal To |
26+
| `>` | Greater than |
27+
| `<` | Less than |
28+
| `==` | Equal to |
29+
| `!=` | Not equal to |
30+
| `>=` | Greater than or equal To |
31+
| `<=` | Less than or equal to |
3232

3333
Comparison operators always return a boolean value (`True` or `False`) when used.
3434

@@ -44,7 +44,7 @@ Comparison operators always return a boolean value (`True` or `False`) when used
4444

4545
### Greater Than Operator (`>`)
4646

47-
Checks if the left hand side operand is larger than the right hand side operand.
47+
Checks if the left-hand side operand is larger than the right-hand side operand.
4848

4949
```python
5050
print(1 > 2)
@@ -55,11 +55,11 @@ print(3.2 > 9)
5555
Running this will give us the following output: ```text False True False ```
5656

5757
This reads almost like plain English! 1 is not greater than 2, hence it returns `False` and prints
58-
it out. 20 is larger than 1, which results the output being `True`, and so on.
58+
it out. 20 is larger than 1, which results in `True` being the output, and so on.
5959

6060
### Less Than Operator (`<`)
6161

62-
Checks if the right hand side operand is larger than the left hand side operand.
62+
Checks if the right-hand side operand is larger than the left-hand side operand.
6363

6464
```python
6565
print(3 < 9)
@@ -77,7 +77,7 @@ False
7777

7878
### Equal To Operator (`==`)
7979

80-
Checks if both left and right hand side operands are exactly equal.
80+
Checks if both left and right-hand side operands are exactly equal.
8181

8282
```python
8383
print(123 == 321)
@@ -119,7 +119,7 @@ True
119119

120120
### Greater Than Or Equal To Operator (`>=`)
121121

122-
Checks if the left hand side operand is either greater than or equal to the right hand side operand.
122+
Checks if the left-hand side operand is either greater than or equal to the right-hand side operand.
123123

124124
```python
125125
print(90 >= 18)
@@ -140,7 +140,7 @@ to 23 which also gives us `True` as the output.
140140

141141
### Less Than Or Equal To Operator (`<=`)
142142

143-
Checks if the right hand side operand is either greater than or equal to the left hand side operand.
143+
Checks if the right-hand side operand is either greater than or equal to the left-hand side operand.
144144

145145
```python
146146
print(4 <= 18)
@@ -284,13 +284,34 @@ minutes = 150
284284
print(minutes // 60)
285285
```
286286

287+
Output:
288+
287289
```text
288290
2
289291
```
290292

293+
??? note "Floor division and negative numbers"
294+
295+
Floor division always rounds **down**, toward negative infinity. With positive numbers this looks
296+
like the decimal part is simply cut off, but with negative numbers it behaves differently:
297+
298+
```python
299+
print(7 // 2)
300+
print(-7 // 2)
301+
```
302+
303+
Output:
304+
305+
```text
306+
3
307+
-4
308+
```
309+
310+
`-7 / 2` is `-3.5`. Rounding down means moving to the next smaller number, which is `-4`, not `-3`.
311+
291312
### Modulus
292313

293-
The modulus operator (`%`) gives us the **remainder** left over after a division. Remember long
314+
The modulus operator (`%`) gives us the **remainder** left over after division. Remember long
294315
division from school? `7 ÷ 2` is `3` with a remainder of `1`, so `7 % 2` is `1`:
295316

296317
```python

0 commit comments

Comments
 (0)