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
In particular, functions are not methods - methods are just those
functions attached to a class. This terminology should be updated
throughout.
I've resisted the temptation to correct American spellings ;)
Just the first four pages done for now.
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,8 +14,8 @@ We hope that we'll be able to make you love technology as much as we do!
14
14
15
15
When you'll finish the tutorial, you will have a simple, working web application: your own blog. We will show you how to put it online, so others will see your work!
Copy file name to clipboardExpand all lines: django/README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,23 @@ You see, when you're building a website, you always need a similiar set of compo
6
6
7
7
Luckily for you other people long ago noticed that web developers face similar problems when building a new site, so they teamed up and created frameworks (Django is one of them) that give you ready components you can use.
8
8
9
-
Frameworks exist to save you from having to re-invent the wheel and help alleviate some of the overhead when you’re building a new site.
9
+
Frameworks exist to save you from having to reinvent the wheel and help alleviate some of the overhead when you’re building a new site.
10
10
11
11
## Why do you need a framework?
12
12
13
-
To understand what Django actually is for, we need a closer look at the servers. First thing is that the server needs to know that you want it to serve you a webpage.
13
+
To understand what Django actually is for, we need a closer look at the servers. The first thing is that the server needs to know that you want it to serve you a webpage.
14
14
15
-
Imagine a mailbox (port) which is monitored for incoming letters (requests). It is done by a web server. The web server also sends a response with a webpage. But when you want to send something, you need to have some content. And Django is something that helps you create the content.
15
+
Imagine a mailbox (port) which is monitored for incoming letters (requests). This is done by a web server. The web server reads the letter, and sends a response with a webpage. But when you want to send something, you need to have some content. And Django is something that helps you create the content.
16
16
17
17
## What happen when someone requests a website from your server?
18
18
19
-
When a request comes to a web server it's passed to Django which tries to figure out what actually is requested. It takes a webpage address first and tries to figure out what to do. This part is done by Django's urlresolver (Note that a website address is called URL - Uniform Resource Locator, so the name *urlresolver* makes sense). It is not very smart - it takes a list of patterns and tries to match the URL. Django checks patterns from top to the bottom and if something is matched then Django passes the request to the associated function (which is called *view*).
19
+
When a request comes to a web server it's passed to Django which tries to figure out what actually is requested. It takes a webpage address first and tries to figure out what to do. This part is done by Django's __urlresolver__ (Note that a website address is called a URL - Uniform Resource Locator, so the name *urlresolver* makes sense). It is not very smart - it takes a list of patterns and tries to match the URL. Django checks patterns from top to the bottom and if something is matched then Django passes the request to the associated function (which is called *view*).
20
20
21
21
Imagine a postman with a letter. She is walking down the street and checks each house number with the one on the letter. If it matches, they put the letter there. This is how the urlresolver works!
22
22
23
23
In the *view* function all interesting things are done: we can look at a database to look for some information. Maybe the user asked to change something in the data? Like a letter saying "Please change description of my job." - the *view* can check if you are allowed to do that, then update the job description for you and send back a message: "Done!". Then the *view* generates a response and Django can send it to the user's web browser.
24
24
25
-
Of course, the description above is a little bit simplified, but you don't need to know all the technical things yet. Knowing a general idea is enough.
25
+
Of course, the description above is a little bit simplified, but you don't need to know all the technical things yet. Having a general idea is enough.
26
26
27
27
So instead of diving too much into details, we will simply start creating something with Django and we will learn all the important parts along the way!
Copy file name to clipboardExpand all lines: how_internet_works/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# How the Internet works?
1
+
# How the Internet works
2
2
3
3
*This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/).*
4
4
@@ -15,11 +15,11 @@ a screen, mouse or a keyboard, because their main purpose is to store data and s
15
15
16
16
Ok, but you want to know how the Internet looks like, right?
17
17
18
-
We made a picture for you! It looks like this:
18
+
We drew you a picture! It looks like this:
19
19
20
20

21
21
22
-
Looks like a mess, right? But in fact it is a network of connected machines (*servers*). Hundreds of thousands of machines! Many, many kilometers of cables around the world! You can visit a Submarine Cable Map website (http://submarinecablemap.com/) to see how complicated the net is. Here is a screenshot from the website:
22
+
Looks like a mess, right? In fact it is a network of connected machines (*servers*). Hundreds of thousands of machines! Many, many kilometers of cables around the world! You can visit a Submarine Cable Map website (http://submarinecablemap.com/) to see how complicated the net is. Here is a screenshot from the website:
23
23
24
24

25
25
@@ -41,7 +41,7 @@ Instead of address with street name, city, zipcode and country, we use IP addres
41
41
42
42
When you send a letter it needs to have certain features to be delivered correctly: address, postmark etc.. You also use language that the receiver understands, right? The same is with *data packets* you send in order to see a website: you use a protocol called HTTP (HyperText TransferProtocol).
43
43
44
-
So basically, when you have a website you need to have a *server* (machine) on which it is. The *server* is waiting for any incoming *requests* (letters that ask you to send your website) and it sends back your website (in another letter).
44
+
So basically, when you have a website you need to have a *server* (machine) where it lives. The *server* is waiting for any incoming *requests* (letters that ask you to send your website) and it sends back your website (in another letter).
45
45
46
46
Since it is a Django tutorial, you will ask what Django does? When you send a response you don't always want to send the same thing to everybody. It is so much better if your letters are personalized especially for the person that has just written to you, right? Django helps you with creating these personalized, interesting letters :).
Copy file name to clipboardExpand all lines: python_introduction/README.md
+28-27Lines changed: 28 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ After running the python command, the prompt changed to `>>>`. For us it means t
19
19
20
20
## Your first Python command!
21
21
22
-
Let's start with something really simple. For example, try typing some math, like `2+3` and hit Enter.
22
+
Let's start with something really simple. For example, try typing some math, like `2 + 3` and hit Enter.
23
23
24
24
>>> 2 + 3
25
25
5
@@ -57,24 +57,24 @@ Nice, huh? To see your name in uppercase, simply type:
57
57
>>> "Ola".upper()
58
58
'OLA'
59
59
60
-
You just used the `upper`__method__ on your string! A method (`upper`) is a set of instructions that Python has to perform on a given object (`"Ola"`) once you call it.
60
+
You just used the `upper`__function__ on your string! A function (`upper`) is a set of instructions that Python has to perform on a given object (`"Ola"`) once you call it.
61
61
62
-
If you want to get the number of letters in your name, there is a method for that too!
62
+
If you want to get the number of letters in your name, there is a function for that too!
63
63
64
64
>>> len("Ola")
65
65
3
66
66
67
-
Wonder why sometimes you call methods by adding `.` at the end of the string (like `"Ola".upper()`) and sometimes you first call a method and place the string in parentheses? Well, in some cases, methods belong to objects, like `upper` that can only be performed on Strings. But sometimes, methods don't belong to anything specific and can be used on different types of objects, just like `len`. That's why we're giving `"Ola"` as a parameter to `len`method.
67
+
Wonder why sometimes you call functions by adding `.` at the end of the string (like `"Ola".upper()`) and sometimes you first call a function and place the string in parentheses? Well, in some cases, functions belong to objects, like `upper` that can only be performed on Strings. In this case, we call the function a __method__. Other times, functions don't belong to anything specific and can be used on different types of objects, just like `len`. That's why we're giving `"Ola"` as a parameter to `len`function.
68
68
69
69
### Summary
70
70
71
71
Ok, enough of strings. So far you've learned about:
72
72
73
73
-__the prompt__ - typing commands (code) into prompt give you Python answers
74
74
-__numbers and strings__ - in Python it's math and text objects
75
-
-__methods__ - are actions in Python. You've used both English-language methods (upper, len) and symbolic ones (+, *).
75
+
-__functions__ - are actions in Python. You've used both English-language functions (upper, len) and symbolic ones (+, *).
76
76
77
-
That's the basic of every programming language you learn. Ready for something harder? We bet you are!
77
+
That's the basics of every programming language you learn. Ready for something harder? We bet you are!
78
78
79
79
## Errors
80
80
@@ -90,16 +90,16 @@ We got our first error! It says that objects of type "int" (integers, whole numb
90
90
>>> len(str(304023))
91
91
6
92
92
93
-
It worked! We used `str`method inside of `len`method. `str` is converting everything to strings.
93
+
It worked! We used `str`function inside of `len`function. `str` is converting everything to strings.
94
94
95
-
-`str`method convert things into __strings__
96
-
-`int`method convert things into __integers__
95
+
-The `str`function converts things into __strings__
96
+
-The `int`function converts things into __integers__
97
97
98
-
> Important: we can convert numbers into text, but we can't convert text into numbers.
98
+
> Important: we can convert numbers into text, but we can't necessarily convert text into numbers - what would `int('hello')` be anyway?
99
99
100
100
## Variables
101
101
102
-
There is a concept in programming called variables. A variable is nothing more than a name for something so you can use it easier. Programmers use these variables to store data, make their code more readable and to not forget what something is.
102
+
An important concept in programming is variables. A variable is nothing more than a name for something so you can use it later. Programmers use these variables to store data, make their code more readable and to not help them remember what things are.
103
103
104
104
Let's say we want to create a new variable called `name`:
105
105
@@ -112,13 +112,13 @@ As you've noticed, your program didn't return anything like it did before. How d
112
112
>>> name
113
113
'Ola'
114
114
115
-
Yikes! Your first variable :)! You can always change what it is:
115
+
Yippee! Your first variable :)! You can always change what it is:
116
116
117
117
>>> name = "Sonja"
118
118
>>> name
119
119
'Sonja'
120
120
121
-
You can use it in methods too:
121
+
You can use it in functions too:
122
122
123
123
>>> len(name)
124
124
5
@@ -134,7 +134,7 @@ Play with this for a while and see what you can do!
134
134
135
135
## Lists
136
136
137
-
Beside strings and integers, Python has all sorts of different types of objects. Now we're going to introduce one called __list__. List is the exact thing you think about now: object that is a list of objects :)
137
+
Beside strings and integers, Python has all sorts of different types of objects. Now we're going to introduce one called __list__. Lists are exactly what you think they are: they are objects which are lists of other objects :)
138
138
139
139
Go ahead and create a list:
140
140
@@ -145,7 +145,7 @@ Yes, it's empty. Not very useful, right? Let's create a list of lottery numbers.
145
145
146
146
>>> lottery = [3, 42, 12, 19, 30, 59]
147
147
148
-
All right, we have a list! What can we do with it? Let's see how many lottery numbers there are in a list. Do you have an idea which method you should use for that? You know this already!
148
+
All right, we have a list! What can we do with it? Let's see how many lottery numbers there are in a list. Do you have an idea which function you should use for that? You know this already!
149
149
150
150
>>> len(lottery)
151
151
6
@@ -154,7 +154,7 @@ Yes! `len` can give you a number of objects in a list. Handy, right? Maybe we wi
154
154
155
155
>>> lottery.sort()
156
156
157
-
This doesn't return anything... because we didn't print it! Try this:
157
+
This doesn't return anything, it just changed the list in place. Let's print it out again and see what happened:
158
158
159
159
>>> print(lottery)
160
160
[3, 12, 19, 30, 42, 59]
@@ -173,14 +173,14 @@ Easy, right? If you want to add something to the list, you can do this by typing
173
173
>>> print(lottery)
174
174
[59, 42, 30, 19, 12, 3, 199]
175
175
176
-
If you want to read only the first number, you can do this by using index. The first object of the list is an object number 0, next one is 1, and so on. Try this:
176
+
If you want to read only the first number, you can do this by using __indexes__. Computer people like to start counting at 0, so the first object of the list is at number 0, next one is 1, and so on. Try this:
177
177
178
178
>>> print(lottery[0])
179
179
59
180
180
>>> print(lottery[1])
181
181
42
182
182
183
-
As you can see, you can access different objects in your list by using its name and index number inside of brackets.
183
+
As you can see, you can access different objects in your list by using its name and index number inside of square brackets.
184
184
185
185
You can find a list of all available list methods here in Python documentation: https://docs.python.org/3/tutorial/datastructures.html
186
186
@@ -241,9 +241,9 @@ You can give Python as many numbers to compare as you want, and it will give you
241
241
242
242
## Boolean
243
243
244
-
Accidently, you just learned about a new type of object in Python. It's __boolean__ -- probably the easiest type there is.
244
+
Accidently, you just learned about a new type of object in Python. It's called a __boolean__ -- probably the easiest type there is.
245
245
246
-
Boolean can be only two things:
246
+
There are only two boolean objects::
247
247
- True
248
248
- False
249
249
@@ -336,21 +336,21 @@ See what happened there?
336
336
In the last three exercises you learned about:
337
337
338
338
-__comparing things__ - in Python you can compare things together using `>`, `>=`, `==`, `<=`, `<` and `and`, `or` operators
339
-
-__boolean__ - type of object that can only held two values: `True` and `False`
340
-
-__if...elif...else__ - statements that are helpful to execute only code that meet given conditions.
339
+
-__boolean__ - a type of object that can only have two values: `True` and `False`
340
+
-__if...elif...else__ - statements that allow you to execute code only when certain conditions are met.
341
341
342
342
Time for the last part of this chapter!
343
343
344
-
## Methods (functions)
344
+
## Your own functions!
345
345
346
-
Remember about methods like `len` that you can execute in Python? Well, good news, you will learn how to write your own functions now!
346
+
Remember functions like `len` that you can execute in Python? Well, good news, you will learn how to write your own functions now!
347
347
348
348
A function is a set of instructions that Python should execute. Each function in Python starts with the keyword `def`, has a name and can have some parameters. Let's start with an easy one:
349
349
350
350
>>> def hi():
351
351
...
352
352
353
-
As you can see, there are the dots again! This means that nothing has really happenned yet... and yes, we need to do a `TAB` before giving our instructions:
353
+
As you can see, there are the dots again! This means that nothing has really happened yet... and yes, we need to do a `TAB` before giving our instructions:
354
354
355
355
>>> def hi():
356
356
... print('Hi there!')
@@ -403,7 +403,7 @@ Let's call the function now:
403
403
>>> hi("Rachel")
404
404
Hi Rachel!
405
405
406
-
Congratulations! You just learned how to write functions :)!
406
+
Congratulations! You just learned how to write functions :)!
407
407
408
408
## Loops
409
409
@@ -435,6 +435,7 @@ Dots again! Remember what goes after dots? Yes, tab :)
435
435
Hi Ola!
436
436
Next girl
437
437
Hi You!
438
+
Next girl
438
439
439
440
As you can see, everything you will put inside `for` statement with `tab` will be repeated for every element of the list `girls`.
440
441
@@ -449,7 +450,7 @@ You can also do `for` on numbers using `range` method:
449
450
4
450
451
5
451
452
452
-
`range` is a method that creates a list of numbers from one number to another (numbers are given by you as parameters).
453
+
`range` is a function that creates a list of numbers from one number to another (numbers are given by you as parameters).
0 commit comments