Skip to content

Commit 11b943d

Browse files
authored
Merge pull request DjangoGirls#813 from DjangoGirls/helenst-comments
Introduce comments in Python tutorial
2 parents 48c7442 + fe94914 commit 11b943d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

en/django_views/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from django.shortcuts import render
1919

2020
Not too much stuff here yet.
2121

22-
Lines that start with `#` are comments - it means that those lines won't be run by Python. Pretty handy, right?
22+
Remember that lines starting with `#` are comments and those lines won't be run by Python.
2323

2424
The simplest *view* can look like this.
2525

en/python_introduction/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,31 @@ Python runs through each test in sequence and prints:
568568
$ python3 python_intro.py
569569
Perfect, I can hear all the details
570570

571+
## Comments
572+
573+
Comments are lines beginning with `#`. You can write whatever you want after the `#` and Python will ignore it. Comments can make your code easier for other people to understand.
574+
575+
Let's see how that looks:
576+
577+
```python
578+
# Change the volume if it's too loud or too quiet
579+
if volume < 20 or volume > 80:
580+
volume = 50
581+
print("That's better!")
582+
```
583+
584+
You don't need to write a comment for every line of code, but they are useful for explaining why your code is doing something, or providing a summary when it's doing something complex.
585+
586+
571587
### Summary
572588

573-
In the last three exercises you learned about:
589+
In the last few exercises you learned about:
574590

575591
- __comparing things__ – in Python you can compare things by using `>`, `>=`, `==`, `<=`, `<` and the `and`, `or` operators
576592
- __Boolean__ – a type of object that can only have one of two values: `True` or `False`
577593
- __Saving files__ – storing code in files so you can execute larger programs.
578594
- __if … elif … else__ – statements that allow you to execute code only when certain conditions are met.
595+
- __comments__ - lines that Python won't run which let you document your code
579596

580597
Time for the last part of this chapter!
581598

0 commit comments

Comments
 (0)