You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -92,7 +92,7 @@ TypeError: unsupported operand type(s) for /: 'str' and 'str'
92
92
Variables are easy to understand. They simply contain data. _[*]_
93
93
94
94
```py
95
-
>>> a = 1# create a variable called a and assigns 1 to it
95
+
>>> a = 1# create a variable called a and assign 1 to it
96
96
>>> a # get the value of a
97
97
1
98
98
>>>
@@ -173,7 +173,7 @@ Now you also understand why typing hello to the prompt didn't work in the beginn
173
173
174
174
### Booleans and None
175
175
176
-
In Python, and many other programming languages, `=` is assigning and `==` is comparing. `a = 1` sets a to 1 and `a == 1` checks if a is 1.
176
+
In Python, and many other programming languages, `=` is assigning and `==` is comparing. `a = 1` sets a to 1 and `a == 1` checks if a equals 1.
177
177
178
178
```py
179
179
>>> a =1
@@ -187,7 +187,7 @@ True
187
187
>>>
188
188
```
189
189
190
-
`a == 2` is the same as `(a == 2) == True`. `a == 2` is more readable, so `== True` needs to be used very rarely.
190
+
`a == 1` is the same as `(a == 1) == True`. `a == 1` is more readable, so `== True` needs to be used very rarely.
191
191
192
192
```py
193
193
>>> a =1
@@ -203,7 +203,7 @@ False
203
203
>>>
204
204
```
205
205
206
-
True and False are boolean values. In Python they're built-in variables. There's also None, which is often used as a default value. All these can be saved to variables, just like integers, floats and strings.
206
+
True and False are boolean values. In Python they're built-in variables. _[*]_There's also None, which is often used as a default value. All these can be saved to variables, just like integers, floats and strings.
207
207
208
208
```py
209
209
>>> a =True
@@ -219,6 +219,8 @@ None
219
219
>>>
220
220
```
221
221
222
+
_[*] In Python 3, True, False and None are actually keywords, but they behave just like variables._
223
+
222
224
There are other comparing operators than `==` too:
223
225
224
226
| Usage | Description | True examples |
@@ -237,7 +239,7 @@ There are other comparing operators than `==` too:
237
239
238
240
_[*] These are not always correct, but this tutorial is about Python's basics, not about cool tricks we can do with it. See [this](https://docs.python.org/3/library/stdtypes.html#truth-value-testing) for more info._
239
241
240
-
There is more than one way to do some things. For example, to check if a is not equal to 1 you could do `a != 1` or `not a == 1`. To check if a is not in b you could do `a not in b` or `not a in b`. However, `!=` and `not in` should be used when possible because they're more convinient once you get used to them.
242
+
There is more than one way to do some things. For example, to check if a is not equal to 1 you could do `a != 1` or `not a == 1`. To check if b does not contain a you could do `a not in b` or `not a in b`. However, `!=` and `not in` should be used in cases like this because they're more convinient once you get used to them.
241
243
242
244
There's also `is`, but don't use it instead of `==` unless you know what you are doing.
0 commit comments