Skip to content

Commit b553634

Browse files
author
python4me
committed
fixing posts
1 parent 103b28b commit b553634

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

_posts/2020-11-26-lecture-notes-1.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Although please note that the print function is run by default in your shell. Th
6868
Hello World!
6969
```
7070

71-
## What objects?
71+
# What objects?
7272

7373
I like to make this course more focused on the object-oriented part of python because although it may sound hard now, this will ease a lot of stuff. You might have found it odd that I've said python prints *objects* to the screen in the 'Hello World!' example. But it is in fact true. Every single 'thing' in python is an object. That `print()` function? Object. That `\n` character? Object. Hello world? Object. Now to avoid confusion and more so to make this language actually work, we need some objects to be different than others and this brings us to **object types**.
7474

@@ -160,7 +160,7 @@ It isn't so
160160
It isn't so
161161
```
162162

163-
### Type conversions
163+
## Type conversions
164164

165165
The last thing you should know about types is that you can convert them to each other. You can use the commands `int()`, `str()`, `list()`, `set()` for example, to do this. If we want to see it in action:
166166

@@ -213,11 +213,11 @@ Here's a table of some data types and examples:
213213
| Sets | set | {'ikbal', 'kuzey'}, {1, 5, 'ikbal'} |
214214
| Lists | list | [0, 1, 3, 4], ['ikbal', 'kuzey', 'ikbal'] |
215215

216-
## Operators
216+
# Operators
217217

218218
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.
219219

220-
### Integer and float operators
220+
## Integer and float operators
221221

222222
Addition
223223

@@ -274,7 +274,7 @@ Raise to the power
274274

275275
**Note:** The same "order of operations" rules apply here too.
276276

277-
### String operators
277+
## String operators
278278

279279
Appension or glueing strings together
280280

@@ -290,7 +290,7 @@ Repetition
290290
'ikbalikbalikbal'
291291
```
292292

293-
### List operators
293+
## List operators
294294

295295
List comprehension is a wide subject and there are lots you can do with lists. They are probably the most important and useful type if we don't count booleans. But I'm not going to be focusing too much on that for this section since it won't be memorable. We'll have a section going in depth with lists soon. Some basic operations you should keep in mind are
296296

@@ -321,7 +321,7 @@ Indexing
321321
3
322322
```
323323

324-
### Assignment operators
324+
## Assignment operators
325325

326326
`=` You know this one.
327327

@@ -338,7 +338,7 @@ Indexing
338338

339339
`*=` and `-=` You should be able to guess.
340340

341-
### Membership operators
341+
## Membership operators
342342

343343
`in`
344344

@@ -347,7 +347,7 @@ Indexing
347347
True
348348
```
349349

350-
### Identity operators
350+
## Identity operators
351351

352352
`is`
353353

@@ -357,7 +357,7 @@ True
357357
True
358358
```
359359

360-
### Comparison operators
360+
## Comparison operators
361361

362362
`==`. Same with `is`. It checks whether objects on the ends are the same.
363363

@@ -393,11 +393,11 @@ True
393393
False
394394
```
395395

396-
## Expressions
396+
# Expressions
397397

398398
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 is 5`. 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**.
399399

400-
## Branching
400+
# Branching
401401

402402
Branching despite it's impressive name only means checking for a condition and running (or not running) code based on that condition. The basic statements for branching is `if`, `elif` and `else`. Remember the comparison operators? This is where we'll use them.
403403

@@ -443,7 +443,7 @@ It is also possible to run this from the terminal on Linux and from `cmd` on Win
443443

444444
Enough Sublime Text, let's get back to how branching works.
445445

446-
### What happened?
446+
## What happened?
447447

448448
1. The interpreter, when parsing the file comes to the if statement and stops.
449449
2. The interpreter checks whether what comes after it is True. So in this case, the interpreter checks whether `True` is True.
@@ -510,7 +510,7 @@ Ikbal is ok.
510510
[Finished in 0.0s]
511511
```
512512

513-
### What happened?
513+
## What happened?
514514

515515
1. The interpreter checked the first if statement. It was `False` because `ikbal` != `'pretty'`.
516516
2. The interpreter checked the `elif` statement and it was `True` because `ikbal` != `'ok'`.
@@ -522,7 +522,7 @@ So from this we can deduce:
522522

523523
Let's test our deduction. We'll set `ikbal` to be `'ok'`. Before running try to guess what'll happen on your own. It's always a good exercise to guess before you run your code so you may have a clue where you go wrong.
524524

525-
### Our guess
525+
## Our guess
526526

527527
1. The interpreter will check `if` `ikbal` == `'pretty'` and it will return `False` because it isn't.
528528
2. The interpreter will check `elif` `ikbal` != `'ok'` and it will also return `False` because `ikbal` **is** `'ok'` and the statement returns `True` only when `ikbal` **isn't** `'ok'`.
@@ -550,7 +550,7 @@ So our guess was correct.
550550

551551
The last thing about branching that you need to know is **nested branching**. As it's name it's about *nesting* different branches.
552552

553-
### Nested branching
553+
## Nested branching
554554

555555
Open a new file and name it whatever you want (It should end with `.py`). This one is so simple that you don't even need an example for it but here goes:
556556

@@ -570,7 +570,7 @@ This number is divisible by 1
570570
[Finished in 0.0s]
571571
```
572572

573-
#### What happened?
573+
### What happened?
574574

575575
1. The interpreter checked `if` the remainder from dividing `num` by 1 was 0. (So it checked whether `num` was divisible by 1) And 5 **is** divisible by 1 so it ran the indented code.
576576
2. It ran the `print()` function
@@ -580,7 +580,7 @@ Note that if the first `if` statement didn't run, the interpreter **wouldn't che
580580

581581
This brings us to the end of branching and to the last subject I want to talk about in this lesson.
582582

583-
## Functions
583+
# Functions
584584

585585
You already saw one of these: the `print()` *function*. You'll come across more and more functions as you delve deeper. Don't make an effort to memorize them all at once, they won't stick. For this reason, this section doesn't focus on different functions you can use for different things but rather how to make your own functions.
586586

@@ -701,9 +701,9 @@ Example:
701701
three thirty pm
702702
```
703703

704-
## Solutions
704+
# Solutions
705705

706-
## Fixing Sublime for Linux
706+
# Fixing Sublime for Linux
707707

708708
1. Go into `Tools > Build System > New Build System...`
709709

0 commit comments

Comments
 (0)