@@ -71,7 +71,7 @@ without variables.
7171
7272Variable names can be multiple characters long. They can contain
7373uppercase characters, numbers and some other characters, but most of the
74- time you should use simple, lowercase variable names. You can also use
74+ time we should use simple, lowercase variable names. You can also use
7575underscores.
7676
7777``` py
@@ -97,7 +97,7 @@ Variable names are case-sensitive, like many other things in Python.
9797
9898Python also has some words that cannot be used as variable names
9999because they have a special meaning. They are called ** keywords** , and
100- you can run ` help('keywords') ` to see the full list if you want to.
100+ we can run ` help('keywords') ` to see the full list if we want to.
101101We'll learn to use most of them later in this tutorial. Trying to use a
102102keyword as a variable name causes a syntax error.
103103
@@ -146,7 +146,7 @@ This is not limited to integers.
146146>> >
147147```
148148
149- Now you also understand why typing hello to the prompt didn't work in
149+ Now we also understand why typing hello to the prompt didn't work in
150150the beginning of this tutorial. But we can assign something to a
151151variable called hello and then type hello:
152152
@@ -174,7 +174,7 @@ False
174174```
175175
176176` a == 1 ` is the same as ` (a == 1) == True ` , but ` a == 1 ` is more
177- readable, so most of the time you shouldn't write ` == True ` anywhere.
177+ readable, so most of the time we shouldn't write ` == True ` anywhere.
178178
179179``` py
180180>> > a = 1
@@ -213,14 +213,30 @@ This is because the prompt never echoes back None. That is handy,
213213because many things result in None, and it would be annoying to see
214214None coming up all the time.
215215
216- If we want to see a None on the interactive prompt, we can use print:
216+ If we want to see a None on the interactive prompt, we can use print.
217217
218218``` py
219219>> > print (thingy)
220220None
221221>> >
222222```
223223
224+ Another confusing thing is that if we do something weird to None we get
225+ error messages that talk about NoneType object. The NoneType object they
226+ are talking about is always None.
227+
228+ ``` py
229+ >> > None .hello # None has no attribute 'hello'
230+ Traceback (most recent call last):
231+ File " <stdin>" , line 1 , in < module>
232+ AttributeError : ' NoneType' object has no attribute ' hello'
233+ >> > None () # None is not callable
234+ Traceback (most recent call last):
235+ File " <stdin>" , line 1 , in < module>
236+ TypeError : ' NoneType' object is not callable
237+ >> >
238+ ```
239+
224240## Other comparing operators
225241
226242So far we've used ` == ` , but there are other operators also. At this
@@ -230,21 +246,20 @@ easy to learn.
230246| Usage | Description | True examples |
231247| -----------| -----------------------------------| -----------------------|
232248| ` a == b ` | a is equal to b | ` 1 == 1 ` |
233- | ` a != b ` | a is not equal to b | ` 1 = = 2 ` |
249+ | ` a != b ` | a is not equal to b | ` 1 ! = 2 ` |
234250| ` a > b ` | a is greater than b | ` 2 > 1 ` |
235251| ` a >= b ` | a is greater than or equal to b | ` 2 >= 1 ` , ` 1 >= 1 ` |
236252| ` a < b ` | a is less than b | ` 1 < 2 ` |
237253| ` a <= b ` | a is less than or equal to b | ` 1 <= 2 ` , ` 1 <= 1 ` |
238254
239- We can also combine multiple comparisons.
255+ We can also combine multiple comparisons. This table assumes that a and
256+ b are Booleans.
240257
241258| Usage | Description | True example |
242259| -----------| -------------------------------------------| -----------------------------------|
243260| ` a and b ` | a is True and b is True | ` 1 == 1 and 2 == 2 ` |
244261| ` a or b ` | a is True, b is True or they're both True | ` False or 1 == 1 ` , ` True or True ` |
245262
246- This table assumes that a and b are Booleans.
247-
248263Another way to combine operations is chaining. For example, ` a < b < c `
249264does the same thing as ` a < b and b < c ` .
250265
0 commit comments