Skip to content

Commit 328bfbc

Browse files
committed
Sphinx build
1 parent 917197b commit 328bfbc

15 files changed

+249
-10111
lines changed

en/_sources/conditional_loops.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ conditional loops are defined with the ``while`` statement::
1010

1111
counter = 0
1212
while counter < 10:
13-
print "in the loop"
13+
print("in the loop")
1414
counter += 1
1515

1616
Move until condition is met

en/_sources/conditionals.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Here are some simple examples::
2121

2222
condition = True
2323
if condition:
24-
print "condition met"
24+
print("condition met")
2525

2626
if not condition:
27-
print "condition not met"
27+
print("condition not met")
2828

2929
direction = -30
3030
if direction > 0 :

en/_sources/logical_operators.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ It is a logical operator::
1818

1919
x = False
2020
if not x :
21-
print "conditon met"
21+
print("conditon met")
2222
else:
23-
print "condition not met"
23+
print("condition not met")
2424

2525
Exercise
2626
--------
2727

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

3233
Can we write a method that only goes forward if the pen is up?
3334

@@ -38,26 +39,26 @@ Solution
3839

3940
def stealthed_forward(distance):
4041
if not turtle.isdown():
41-
forward(distance)
42+
turtle.forward(distance)
4243

4344

4445

4546

4647
This and that or something else
4748
===============================
4849

49-
Two easy to understand operators are ``and`` and ``or``. They do exactly whay
50-
the sound like: combine two statements in a way both have be true (``and``) or
50+
Two easy to understand operators are ``and`` and ``or``. They do exactly what
51+
they sound like: combine two statements in a way both have be true (``and``) or
5152
at least one of them has to be true (``or``)::
5253

5354
if 1 < 2 and 4 > 2:
54-
print "condition met"
55+
print("condition met")
5556

5657
if 1 < 2 and 4 < 10:
57-
print "condition not met"
58+
print("condition not met")
5859

5960
if 4 < 10 or 1 < 2:
60-
print "condition met"
61+
print("condition met")
6162

6263
You are not restricted to one logical operator. You can combine as may as you
6364
want.

en/_sources/loops.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ concept in Python called looping, which we will elaborate later on. For now,
99
take that easy example::
1010

1111
for i in range(10):
12-
print "Hello!"
12+
print("Hello!")
1313

1414
Drawing a dashed line
1515
=====================
@@ -18,8 +18,8 @@ Exercise
1818
--------
1919

2020
Draw a dashed line. You can move the turtle without tracing a line behind you
21-
with the ``turtle.up()`` function; put it back on the ground with
22-
``turtle.down()``.
21+
with the ``turtle.penup()`` function; put it back on the ground with
22+
``turtle.pendown()``.
2323

2424
.. image:: /images/dashed.png
2525

@@ -30,9 +30,9 @@ Solution
3030

3131
for i in range(10):
3232
turtle.forward(15)
33-
turtle.up()
33+
turtle.penup()
3434
turtle.forward(5)
35-
turtle.down()
35+
turtle.pendown()
3636

3737
Bonus
3838
-----

en/_sources/names.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ In Python syntax, that very statement translates to::
1818

1919
x = 5
2020

21-
After that statement, if you do ``print x``, it will actually output its value
21+
After that statement, if you do ``print(x)``, it will actually output its value
2222
--- 5. You can well use that for turtle too::
2323

2424
turtle.forward(x)
2525

2626

27-
.. note:: You can not save numbers in variables, like we did here for "x", but
28-
you can actually save various kinds of things in them. A typical other thing
29-
you want to have store often is a "string" - a line of text. Strings are
30-
indicated with a starting and a leading \". You'll learn about this and
27+
.. note:: You can not only save numbers in variables, like we did here for "x",
28+
but you can actually save various kinds of things in them. A typical other
29+
thing you want to have store often is a "string" - a line of text. Strings
30+
are indicated with a starting and a leading \". You'll learn about this and
3131
other types, as those are called in Python, and what you can do with them
3232
later on.
3333

@@ -76,7 +76,12 @@ Draw a house.
7676

7777
.. image:: /images/house.png
7878

79-
You can calculate the length of the diagonal line with Pythagoras. That value
80-
is a good candidate for a name binding.
79+
You can calculate the length of the diagonal line with Pythagoras. That value is
80+
a good candidate for a name binding. To calculate the square root of a number in
81+
Python, import the *math* module and use the ``math.sqrt()`` function. The
82+
square of a number is calculated with the ``\*\*`` operator::
8183

84+
import math
85+
86+
c = math.sqrt(a**2 + b**2)
8287

en/_sources/simple_drawing.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ to move forward, ``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

36+
If you put the commands into a file, you might have recognized that the turtle
37+
window vanishes after the turtle finished its movement. To prevent that, just
38+
put ``turtle.exitonclick()`` at the bottom of your file::
39+
40+
import turtle
41+
42+
turtle.forward(25)
43+
44+
turtle.exitonclick()
45+
3646
Drawing a square
3747
================
3848

0 commit comments

Comments
 (0)