Skip to content

Commit e6663a6

Browse files
committed
Changes from install party review
1 parent 3cbd0d7 commit e6663a6

File tree

10 files changed

+94
-75
lines changed

10 files changed

+94
-75
lines changed

docs/en/conditional_loops.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ combination with infinite loops.
4545
Exercise
4646
--------
4747

48-
Write a ``while`` loop with a condition that is always true to draw a spiral.
48+
Write a ``while`` loop with a condition that is always True to draw a spiral.
4949
Interrupt the loop when the turtle reaches a certain distance from the center.
5050
Use the function ``turtle.distance(x, y)`` to get the turtle's distance to the
5151
point defined by the coordinates ``x`` and ``y``.

docs/en/conditionals.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ Conditional statements
44
Introduction
55
============
66

7-
So far we have accomplished predefined tasks, but in all honesty we were accomplishing no better achievements than the 18th century automata, or the music boxes following one set of instruction to the end. What makes programming so much more powerful is conditional statements. This is the ability to *test* a variable (or a name) against a value and act in one way if the condition is met by the variable or an other way if not. They are also commonly called by programmers *if statements*.
7+
So far we have accomplished predefined tasks, but in all honesty we were accomplishing no better achievements than the 18th century automata, or the music boxes following one set of instruction to the end. What makes programming so much more powerful are conditional statements. This is the ability to *test* a variable against a value and act in one way if the condition is met by the variable or an other way if not. They are also commonly called by programmers *if statements*.
88

99
To know if a condition is *True* of *False*, we need a new type of data:
1010
the booleans. They allow logical operations.
11-
A logic statement or operation can be evaluated to be *true* or *false*.
11+
A logic statement or operation can be evaluated to be *True* or *False*.
1212
Our conditional statement can then be understood like this:
1313

14-
**if** *(evaluation of a condition returns true)* **then** *do some operation* **else** *do an other operation*.
15-
And any operation that can be evaluated as *true* or *false* can but put to the test. All comparisons return *true* or *false*: *=,>,<*.
16-
14+
**if** *(evaluation of a condition returns true)* **then** *do some operation*
15+
**else** *do an other operation*. And any operation that can be evaluated as
16+
*True* or *False* can be put to the test. All comparisons return *True* or
17+
*False*: ``==``, ``>``, ``<``.
1718

1819
Examples
1920
========
21+
2022
Here are some simple examples::
2123

2224
condition = True
@@ -31,22 +33,21 @@ Here are some simple examples::
3133
turtle.forward(direction)
3234
else:
3335
turtle.left(180)
34-
turtle.forward (-direction)
35-
36+
turtle.forward(-direction)
3637

3738
Condition an action
3839
===================
3940

4041
Exercise
4142
--------
4243

43-
Let's try to make our turtle to stop when it reaches the end
44-
of the window. Let's only take into account horizontal movements.
45-
We want the turtle to go forward for a specified distance (taken as a function parameter) until it reaches this distance, or stop and turn around if it reaches the border of the screen.
44+
Let's try to make our turtle stop when it reaches the end of the window. Let's
45+
only take into account horizontal movements. We want the turtle to go forward
46+
for a specified distance (taken as a function parameter) until it reaches this
47+
distance and stops.
4648

4749
.. note::
4850
* We start from the center of the screen, which has coordinate (0;0)
49-
* We won't turn, until we reach the boundary our turtle wants to get away as quickly as possible
5051
* We can get the x coordinate of our turtle with the function ``turtle.xcor()``
5152
* We can get the width of the screen with the function ``turtle.window_width()``
5253

@@ -62,7 +63,6 @@ Solution
6263
turtle.forward(distance)
6364
else:
6465
turtle.forward(turtle.window_width()/2 - turtle.xcor())
65-
turtle.left(180)
6666

6767
Bonus exercise
6868
--------------
@@ -83,7 +83,7 @@ Solution
8383
future_x_coord = turtle.xcor() + distance
8484
else:
8585
future_x_coord = turtle.xcor() - distance
86-
86+
8787
diff = turtle.window_width()/2 - future_x_coord
8888
if diff > 0 :
8989
turtle.forward(distance)

docs/en/functions.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
User-defined funtions
2-
*********************
1+
User-defined functions
2+
**********************
33

44
Introduction
55
============
@@ -22,14 +22,18 @@ A function can be defined with the ``def`` keyword in Python::
2222
turtle.forward(50)
2323
turtle.backward(50)
2424

25-
You can access names in functions as well::
25+
You can access variables in functions as well::
2626

2727
size = 50
2828
def line_without_moving():
2929
turtle.forward(size)
3030
turtle.backward(size)
3131

32-
.. note:: Python uses *whitespaces to identify blocks of code* belonging together. While other languages use special characters (like curly brackets) in python a block is introduced with a colon at the end of the line and commands within a deeper identation level - ususally 4 spaces. The block ends with the first line with a lesser identation level.
32+
.. note:: Python uses *whitespace to identify blocks of code* belonging
33+
together. While other languages use special characters (like curly brackets)
34+
in Python a block is introduced with a colon at the end of the line and
35+
commands within a deeper indentation level - usually 4 spaces. The block ends
36+
with the first line with a lesser indentation level.
3337

3438
A function for a square
3539
=======================

docs/en/functions_parameters.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ Functions with parameters
33
Introduction
44
============
55

6-
Now we know how to *factorize* this code a little. But functions as we have defined them so far are not flexible. The variables are defined inside the function, and we need to rewrite a whole function to change the value of an angle, or a distance in it.
6+
Now we know how to *factorize* this code a little. But functions as we have
7+
defined them so far are not flexible. The variables are defined inside the
8+
function, and we need to rewrite a whole function to change the value of an
9+
angle, or a distance in it.
710

8-
That is why we need to be able to give parameters, or also called *arguments* so that *names* we use in the function can be used with different values each time we call the function:
11+
That is why we need to be able to give parameters, or also called *arguments*
12+
so that *variables* we use in the function can be used with different values
13+
each time we call the function:
914

1015
Remember how we defined the function ``line_without_moving`` in the previous section::
1116

@@ -19,15 +24,18 @@ We can improve it by giving it a parameter::
1924
turtle.forward(length)
2025
turtle.backward(length)
2126

22-
The parameter acts as a *name* only known inside the function's definition. We use the newly defined function by calling it with the value we want the parameter to have like this::
27+
The parameter acts as a *variable* only known inside the function's definition.
28+
We use the newly defined function by calling it with the value we want the
29+
parameter to have like this::
2330

2431
line_without_moving(50)
2532
line_without_moving(40)
2633

27-
We have been using functions with parameters since the beginning of the tutorial with the *forward*, *left*, etc...
34+
We have been using functions with parameters since the beginning of the
35+
tutorial with the *forward*, *left*, etc...
2836

29-
30-
And we can put as many arguments (or parameters) as we want, separating them with commas and giving them different names::
37+
And we can put as many arguments (or parameters) as we want, separating them
38+
with commas and giving them different names::
3139

3240
def tilted_line_without_moving(length, angle):
3341
turtle.left(angle)
@@ -40,18 +48,18 @@ A parameterized function for a variable size hexagon
4048

4149
Exercise
4250
--------
43-
Write a function that takes allows you to draw hexagons of any size you want, each time you call the function.
44-
4551

52+
Write a function that allows you to draw hexagons of any size you want, each
53+
time you call the function.
4654

4755
A function of several parameters
4856
================================
4957

5058
Exercise
5159
--------
5260

53-
Write a function that draws a honeycomb with a variable number of hexagons, of variable sizes
54-
61+
Write a function that draws a honeycomb with a variable number of hexagons, of
62+
variable sizes.
5563

5664
Solution
5765
--------

docs/en/getting_started.rst

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Getting started
44
Starting Python
55
===============
66

7-
After installing Python on your system successfully, you can start the interactive Python prompt by typing ``python`` in the command and press <enter>. It will show you some context information about Python similar to this::
7+
After installing Python on your system successfully, you can start the interactive Python prompt by typing ``python`` in the command and press <enter>. It will show you some context information about Python similar to this
8+
9+
.. code-block:: bash
810
911
Python 2.7.2 (default, Feb 1 2012, 00:28:57)
1012
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
@@ -18,27 +20,32 @@ Those three ">>>" in the last line indicate that you are now in the interactive
1820

1921
print("Hello world")
2022

21-
press <enter> and see what happens. You will now see the phrase "Hello world" appear and then Python will bring you back to the interactive input, where you could enter another command now::
23+
Press <enter> and see what happens. You will now see the phrase "Hello world" appear and then Python will bring you back to the interactive input, where you could enter another command now::
2224

2325
>>> print("Hello world")
2426
Hello world
2527
>>>
2628

29+
.. TODO: exit interpreter
2730
2831
Running Python files
2932
====================
3033

31-
But you don't want to type everything into the Python shell everytime. Instead
34+
But you don't want to type everything into the Python shell every time. Instead
3235
having a file with commands and handing that to Python to execute it would be
33-
much better. In order to do that you can just pass a file name to the Python
34-
command in your shell and it will execute that file. Let's try that. Just open
35-
the file "hello.py" in this directory in your favourite text editor and paste
36-
the print command from above. Now save that file, go back the command line and
37-
type::
36+
much better. In order to do that you can just pass a file name to the ``python``
37+
command in your shell and it will execute that file. Let's try that. Create a
38+
file ``hello.py`` in your current directory with your favorite text editor and
39+
paste the print command from above. Now save that file, go back the command line
40+
and type
41+
42+
.. code-block:: bash
3843
39-
Python hello.py
44+
python hello.py
4045
41-
When pressing <enter> now, the file is executed and you see the print as before. But this time, after Python executed all commands from that file, it exited instead of going back to the interactive shell. In some opearting systems (and depending on your setup) you might also be able to just double click on the hello.py file to execute it
46+
When pressing <enter> now, the file is executed and you see the print as before.
47+
But this time, after Python executed all commands from that file, it exited
48+
instead of going back to the interactive shell.
4249

4350
.. note:: Wordpad, TextEdit, Notepad and Word are **not** suited text editors. If you are unsure whether you already have a usable editor, you might want to download and install `Sublime Text2 <http://www.sublimetext.com/>`_. Sophisticated editors like this also take care of identation and help you run and debug your code.
4451

docs/en/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Table of contents:
99

1010
getting_started
1111
simple_drawing
12-
names
12+
variables
1313
functions
1414
loops
1515
functions_parameters

docs/en/logical_operators.rst

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Introduction
55
============
66

77
Conditionals are a nice way to make decisions by asking if something equals
8-
true or not. But often one condition is not enough.
9-
We may want to take the opposite of your result. Or for instance if we want to
8+
True or not. But often one condition is not enough.
9+
We may want to take the opposite of our result. Or for instance if we want to
1010
make a decision upon ``turtle.xcor()`` and ``turtle.ycor()`` we have to combine
1111
them. This can be done with logical operators.
1212

@@ -25,12 +25,12 @@ It is a logical operator::
2525
Exercise
2626
--------
2727

28-
The turtle gives us a useful function to know if it is writing or not: ``turtle.isdown()``.
29-
This function returns *True* if the turtle is writing. As we have seen earlier, the function
28+
The turtle gives us a useful function to know if it is drawing or not: ``turtle.isdown()``.
29+
This function returns *True* if the turtle is drawing. As we have seen earlier, the function
3030
``turtle.penup()`` and ``turtle.pendown()`` toggle between writing while moving,
3131
or just moving without a trace.
3232

33-
Can we write a method that only goes forward if the pen is up?
33+
Can we write a function that only goes forward if the pen is up?
3434

3535
Solution
3636
--------
@@ -42,8 +42,6 @@ Solution
4242
turtle.forward(distance)
4343

4444

45-
46-
4745
This and that or something else
4846
===============================
4947

@@ -54,7 +52,7 @@ at least one of them has to be true (``or``)::
5452
if 1 < 2 and 4 > 2:
5553
print("condition met")
5654

57-
if 1 < 2 and 4 < 10:
55+
if 1 > 2 and 4 < 10:
5856
print("condition not met")
5957

6058
if 4 < 10 or 1 < 2:
@@ -66,9 +64,9 @@ want.
6664
Exercise
6765
--------
6866

69-
Create a function that accepts the argument ``angle`` and moves the turtle into
70-
that direction until either the vertical or horizontal distance to the center
71-
exceeds 100.
67+
Create a function that accepts the argument ``angle`` and moves the turtle
68+
forward into that direction until either the vertical or horizontal distance to
69+
the center exceeds 100.
7270

7371
Solution
7472
--------
@@ -81,10 +79,10 @@ Solution
8179
y = turtle.ycor()
8280
while x > -100 and x < 100 and y > -100 and y < 100:
8381
turtle.forward(10)
82+
x = turtle.xcor()
83+
y = turtle.ycor()
8484

8585
Bonus
8686
-----
8787

88-
Execute the ``move_to_square_border()`` function multiple times with different
89-
angles. Use the ``turtle.home()`` function to make the turtle jump to the
90-
center after each line.
88+
Can you use this to draw a star?

docs/en/loops.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Introduction
66

77
One more thing: Our programs often featured repetition. There is a powerful
88
concept in Python called looping, which we will elaborate later on. For now,
9-
take that easy example::
9+
take this easy example::
1010

1111
for i in range(10):
1212
print("Hello!")

docs/en/simple_drawing.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ Before you can use turtle, you have to import it::
2828
.. image:: /images/left.png
2929

3030

31-
The ``turtle.forward(...)`` function takes the number of pixels which you want
32-
to move forward, ``turtle.left(...)`` takes a number of degrees which you want
31+
The ``turtle.forward(...)`` function tells the turtle to move forward
32+
by the given distance. ``turtle.left(...)`` takes a number of degrees which you want
3333
to rotate to the left. (There are ``turtle.backward(...)`` and
3434
``turtle.right(...)``, too.)
3535

3636
If you put the commands into a file, you might have recognized that the turtle
3737
window vanishes after the turtle finished its movement. To prevent that, just
38-
put ``turtle.exitonclick()`` at the bottom of your file::
38+
put ``turtle.exitonclick()`` at the bottom of your file. Now you can click on
39+
the window to close it.
40+
41+
::
3942

4043
import turtle
4144

@@ -78,9 +81,9 @@ Bonus
7881
-----
7982

8083
If you want to get creative, you can modify your shape with the
81-
``turtle.width(...)`` and ``turtle.color(...)`` functions. If you cannot
82-
figure out the *signature* of a function (that is the syntax and semantics of
83-
it, say, number of parameters and their meaning) you can use ``help(color)``.
84+
``turtle.width(...)`` and ``turtle.color(...)`` functions. If you cannot figure
85+
out the *signature* of a function (that is the syntax and semantics of it, say,
86+
number of parameters and their meaning) you can use ``help(turtle.color)``.
8487

8588
.. caution::
8689

@@ -114,7 +117,7 @@ Solution
114117
Bonus
115118
-----
116119

117-
How about a triangle? (A triangle with 120 degrees angles will have all legs
120+
How about a triangle? (A triangle with 120 degrees angles will have all sides
118121
equally sized.)
119122

120123

0 commit comments

Comments
 (0)