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
Copy file name to clipboardExpand all lines: _posts/2020-11-26-lecture-notes-1.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,21 +125,21 @@ Tuples are just like lists but the difference is that you can't change them. Aga
125
125
<class'bool'>
126
126
```
127
127
128
-
Another type that we have are`boolean`. This is simple a True or False statement. We'll make use of this when we get to how to write logical *expressions*.
128
+
Another type that we have is`boolean`. This is a simple True or False statement. We'll make use of this when we get to how to write logical *expressions*.
129
129
130
130
```python
131
131
>>>type('')
132
132
<class'str'>
133
133
```
134
134
135
-
The last type, at least for now is `string`. Strings are anything you put inside ' 's you can also use " "s but you should be consistent with which one you use. Most people think about *writing* when thinking about strings. Yes that is true, but only to an extend. I wouldn't like to confuse you but `'3'` is also a string.
135
+
The last type, at least for now is `string`. Strings are anything you put inside ' 's. You can also use " "s but you should be consistent with what you use. Most people think about *writing* when thinking about strings. Yes that is true, but only to an extend. I wouldn't like to confuse you but `'3'` is also a string.
136
136
137
137
```python
138
138
>>>type('3')
139
139
<class'str'>
140
140
```
141
141
142
-
So just keep in mind that anything between quotes is a string although strings have text inside them mot of the time, they can have any character you want. (Except the escape character, i.e. `\`)
142
+
So just keep in mind that anything between quotes is a string although strings have text inside them most of the time, they can have any character you want. (Except the escape character on it's own, i.e. `\`)
143
143
144
144
This brings us to another thing you should note related to `print()`. The escape character: `\`. Backwards slash--unless it's used before certain characters like `n` and `t`--will disable the next character. What do I mean by this? Let's see:
145
145
@@ -200,22 +200,22 @@ So here we face a NameError. And it clearly tells us that python doesn't know wh
200
200
awesome
201
201
```
202
202
203
-
So by defining this meaningless text, we made it a **variable**. Our `ikbal` variable has the value "awesome." And we did it by using the `=` operator. You should note that there are **reserved words** that you can't use for variables because they already have a meaning. Altough, when you're using sublime, these words will be highlighted so you won't have any trouble. These words are: and, as, assert, break, class, continue, def, del, elif, else, except, False, finally, for, from, global, if, import, in, is, lambda, nonlocal, None, not, or, pass, raise, return, True, try, while,with,andyield.
203
+
So by defining this meaningless text, we made it a **variable**. Our `ikbal` variable has the value `"awesome"`. And we did it by using the `=` operator. You should note that there are **reserved words** that you can't use for variables because they already have a meaning. Altough, when you're using sublime, these words will be highlighted so you won't have any trouble. These words are: `and`, `as`, `assert`, `break`, `class`, `continue`, `def`, `del`, `elif`, `else`, `except`, `False`, `finally`, `for`, `from`, `global`, `if`, `import`, `in`, `is`, `lambda`, `nonlocal`, `None`, `not`, `or`, `pass`, `raise`, `return`, `True`, `try`, `while`, `with`, `and`, `yield`.
All these brings us to operators. Yes, I know, it's not as exiting to learn about data types and these basic stuff, but it'll be over soon. Operators are just like in math. They operate. I don't think high level explanations are very memorable so let's see some operators. Operators are *type-specific*, meaning that either they don't work for different types or that they work differently for different types. Don't try to memorize these. Try writing code that uses these operators. That'll make them stick more easily.
218
+
All these brings us to operators. Yes, I know, it's not as exciting to learn about data types and these basic stuff, but it'll be over soon. Operators are just like in math. They operate. I don't think high level explanations are very memorable so let's see some operators. Operators are *type-specific*, meaning that either they don't work for different types or that they work differently for different types. Don't try to memorize these. Try writing code that uses these operators. That'll make them stick more easily.
219
219
220
220
## Integer and float operators
221
221
@@ -374,9 +374,9 @@ True
374
374
True
375
375
```
376
376
377
-
There's also >, <, >=, <= but I'm sure you can guess what they do.
377
+
There's also `>`, `<`, `>=`, `<=` but I'm sure you can guess what they do.
378
378
379
-
### Logical Operators
379
+
## Logical Operators
380
380
381
381
`and`, `or`
382
382
@@ -395,7 +395,7 @@ False
395
395
396
396
# Expressions
397
397
398
-
To be honest, all we were doing in the last section was checking the values of expressions. When you use objects with operators, you get expressions. For example `a = 5`is an expression just like `a is5`. Some of these expressions are logical arguments. You may have noticed that in a big part of the operators we just saw, the shell returned either TrueorFalse. These expressions which returnTrueorFalse are called logical statements just like in math. This brings us to **branching**.
398
+
To be honest, all we were doing in the last section was checking the values of expressions. When you use objects with operators, you get expressions. For example `a = 5`is an expression just like `a is5`. Some of these expressions are logical arguments. You may have noticed that in a big part of the operators we just saw, the shell returned either `True`or`False`. These expressions which return`True`or`False` are called logical statements just like in math. This brings us to **branching**.
0 commit comments