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: en/python_introduction/README.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Using double quotes:
63
63
>>> "Runnin' down the hill"
64
64
"Runnin' down the hill"
65
65
66
-
or escaping apostrophe with a backslash (`\`):
66
+
or escaping apostrophe with a backslash (`\`):
67
67
68
68
>>> 'Runnin\' down the hill'
69
69
"Runnin' down the hill"
@@ -177,7 +177,7 @@ As we'll see later, `print()` is also useful when we want to print things from i
177
177
178
178
## Lists
179
179
180
-
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 :)
180
+
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: objects which are lists of other objects :)
181
181
182
182
Go ahead and create a list:
183
183
@@ -372,7 +372,7 @@ There are only two Boolean objects:
372
372
- True
373
373
- False
374
374
375
-
But for Python to understand this, you need to always write it as True (first letter uppercased, with the rest of the letter lowercased). __true, TRUE, tRUE won't work -- only True is correct.__ (The same applies to False as well, of course.)
375
+
But for Python to understand this, you need to always write it as 'True' (first letter uppercased, with the rest of the letter lowercased). __true, TRUE, tRUE won't work -- only True is correct.__ (The same applies to 'False' as well, of course.)
376
376
377
377
Booleans can be variables, too! See here:
378
378
@@ -417,7 +417,7 @@ Earlier, we picked out a code editor from the [code editor](../code_editor/READM
417
417
print('Hello, Django girls!')
418
418
```
419
419
420
-
> **Note** You should notice one of the coolest thing about code editors: colours! In the Python console, everything was the same colour, but now you should see that the `print` function is a different colour from the string inside it. That's called "syntax highlighting", and it's a really useful helping hand when coding. Watch out for the colour of things, and you'll get a hint for when you forget to close a string, or make a typo in a keyword name (like the `def` in a function, which we'll see below). This is one of the reasons we use a code editor :)
420
+
> **Note** You should notice one of the coolest thing about code editors: colours! In the Python console, everything was the same colour, now you should see that the `print` function is a different colour from the string. This is called "syntax highlighting", and it's a really useful feature when coding. The colour of things will give you hints, such as unclosed strings, or a typo in a keyword name (like the `def` in a function, which we'll see below). This is one of the reasons we use a code editor :)
421
421
422
422
423
423
Obviously, you're a pretty seasoned python developer now, so feel free to write some code that you've learned today.
@@ -466,14 +466,14 @@ If we saved this and ran it, we'd see an error like this:
466
466
^
467
467
SyntaxError: unexpected EOF while parsing
468
468
469
-
Python expects us to give further instructions to it which are supposed to be executed if the condition `3 > 2` turns out to be true (or `True` for that matter). Let’s try to make Python print “It works!”. Change your code in your **python_intro.py** file to this:
469
+
Python expects us to give further instructions to it which are executed if the condition `3 > 2` turns out to be true (or `True` for that matter). Let’s try to make Python print “It works!”. Change your code in your **python_intro.py** file to this:
470
470
471
471
```python
472
472
if3>2:
473
473
print('It works!')
474
474
```
475
475
476
-
Notice how we've indented the next line of code by 4 spaces? We need to do this so Python knows what code to run if the code results in true. You can do one space, but nearly all Python programmers do 4 to make things look neat. A single tab will also count as 4 spaces.
476
+
Notice how we've indented the next line of code by 4 spaces? We need to do this so Python knows what code to run if the result is true. You can do one space, but nearly all Python programmers do 4 to make things look neat. A single tab will also count as 4 spaces.
477
477
478
478
Save it and give it another run:
479
479
@@ -491,7 +491,7 @@ else:
491
491
print('5 is not greater than 2')
492
492
```
493
493
494
-
When this was run it would print out:
494
+
When this is ran it will print out:
495
495
496
496
$ python3 python_intro.py
497
497
5 is indeed greater than 2
@@ -530,7 +530,7 @@ Time for the last part of this chapter!
530
530
531
531
Remember functions like `len()` that you can execute in Python? Well, good news, you will learn how to write your own functions now!
532
532
533
-
A function is a sequence of instructions that Python should execute. Each function in Python starts with the keyword `def`, is given a name and can have some parameters. Let's start with an easy one. Replace the code in **python_intro.py** with the following:
533
+
A function is a sequence of instructions that Python should execute. Each function in Python starts with the keyword `def`, is given a name, and it can have some parameters. Let's start with an easy one. Replace the code in **python_intro.py** with the following:
534
534
535
535
```python
536
536
defhi():
@@ -570,7 +570,7 @@ def hi(name):
570
570
hi()
571
571
```
572
572
573
-
As you can see, we needed to put two indents before the `print` function, because `if`needs to know what should happen when the condition is met. Let's see how it works now:
573
+
Remember: The `print` function is indented four spaces within the `if`statement. This is because the function runs when the condition is met. Let's see how it works now:
574
574
575
575
$ python3 python_intro.py
576
576
Traceback (most recent call last):
@@ -586,7 +586,7 @@ Let's fix it at the bottom of the file:
586
586
hi("Ola")
587
587
```
588
588
589
-
and run it again:
589
+
And run it again:
590
590
591
591
$ python3 python_intro.py
592
592
Hi Ola!
@@ -597,12 +597,12 @@ And if we change the name?
597
597
hi("Sonja")
598
598
```
599
599
600
-
and run it:
600
+
And run it:
601
601
602
602
$ python3 python_intro.py
603
603
Hi Sonja!
604
604
605
-
Now what do you think will happen if you write another name in there? (Not Ola or Sonja) Give it a try and see if you're right. It should print out this:
605
+
Now, what do you think will happen if you write another name in there? (Not Ola or Sonja) Give it a try and see if you're right. It should print out this:
606
606
607
607
Hi anonymous!
608
608
@@ -622,11 +622,11 @@ Let's call the code now:
622
622
$ python3 python_intro.py
623
623
Hi Rachel!
624
624
625
-
Congratulations! You just learned how to write functions :)!
625
+
Congratulations! You just learned how to write functions! :)
626
626
627
627
## Loops
628
628
629
-
That's the last part already. That was quick, right? :)
629
+
This is the last part already. That was quick, right? :)
630
630
631
631
As we mentioned, programmers are lazy, they don't like to repeat themselves. Programming is all about automating things, so we don't want to greet every person by their name manually, right? That's where loops come in handy.
632
632
@@ -642,7 +642,7 @@ We want to greet all of them by their name. We have the `hi` function to do that
642
642
for name in girls:
643
643
```
644
644
645
-
The ```for``` statement behaves similarly to the ```if``` statement, code below both of these need to be indented four spaces.
645
+
The ```for``` statement behaves similarly to the ```if``` statement; code below both of these need to be indented four spaces.
646
646
647
647
Here is the full code that will be in the file:
648
648
@@ -656,7 +656,7 @@ for name in girls:
656
656
print('Next girl')
657
657
```
658
658
659
-
and when we run it:
659
+
And when we run it:
660
660
661
661
$ python3 python_intro.py
662
662
Hi Rachel!
@@ -691,7 +691,7 @@ Note that the second of these two numbers is not included in the list that is ou
691
691
692
692
## Summary
693
693
694
-
That's it. __You totally rock!__ This really wasn't so easy, so you should feel proud of yourself. We're definitely proud of you for making it to here!
694
+
That's it. __You totally rock!__ This was a tricky chapter, so you should feel proud of yourself. We're definitely proud of you for making it this far!
695
695
696
696
You might want to briefly do something else - stretch, walk around for a bit, rest your eyes - before going on to the next chapter. :)
0 commit comments