summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial/introduction.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2017-10-14 14:36:08 (GMT)
committerGitHub <noreply@github.com>2017-10-14 14:36:08 (GMT)
commit8c26a34f93db7ae96b42bcce6b557437436c7721 (patch)
tree2c0d4531ddee56b1e42f7f31ced09e58ea359178 /Doc/tutorial/introduction.rst
parent073150db39408c1800e4b9e895ad0b0e195f1056 (diff)
downloadcpython-8c26a34f93db7ae96b42bcce6b557437436c7721.zip
cpython-8c26a34f93db7ae96b42bcce6b557437436c7721.tar.gz
cpython-8c26a34f93db7ae96b42bcce6b557437436c7721.tar.bz2
bpo-31757: Make Fibonacci examples consistent (#3991)
Diffstat (limited to 'Doc/tutorial/introduction.rst')
-rw-r--r--Doc/tutorial/introduction.rst18
1 files changed, 10 insertions, 8 deletions
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index 8956aa5..2fa894a 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -458,16 +458,18 @@ First Steps Towards Programming
===============================
Of course, we can use Python for more complicated tasks than adding two and two
-together. For instance, we can write an initial sub-sequence of the *Fibonacci*
-series as follows::
+together. For instance, we can write an initial sub-sequence of the
+`Fibonacci series <https://en.wikipedia.org/wiki/Fibonacci_number>`_
+as follows::
>>> # Fibonacci series:
... # the sum of two elements defines the next
... a, b = 0, 1
- >>> while b < 10:
- ... print(b)
+ >>> while a < 10:
+ ... print(a)
... a, b = b, a+b
...
+ 0
1
1
2
@@ -483,7 +485,7 @@ This example introduces several new features.
first before any of the assignments take place. The right-hand side expressions
are evaluated from the left to the right.
-* The :keyword:`while` loop executes as long as the condition (here: ``b < 10``)
+* The :keyword:`while` loop executes as long as the condition (here: ``a < 10``)
remains true. In Python, like in C, any non-zero integer value is true; zero is
false. The condition may also be a string or list value, in fact any sequence;
anything with a non-zero length is true, empty sequences are false. The test
@@ -516,11 +518,11 @@ This example introduces several new features.
or end the output with a different string::
>>> a, b = 0, 1
- >>> while b < 1000:
- ... print(b, end=',')
+ >>> while a < 1000:
+ ... print(a, end=',')
... a, b = b, a+b
...
- 1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
+ 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
.. rubric:: Footnotes