Skip to content

Commit b6432ff

Browse files
committed
enhanced explanations and small fixes
1 parent 0f26430 commit b6432ff

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎source/ch_6_loopsanditeration.ptx‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
So this section will just serve as a reference for the differences in syntax.
1111
</p>
1212

13-
<p>
14-
In Python the easiest way to write a definite loop is using the <c>for loop</c> in conjunction with the <c>range</c> function.
13+
<p><idx><c>for</c> loop</idx>
14+
A <term>definite loop</term> is a loop that is executed a specific or definite number of times. In Python, the easiest way to write a definite loop is using the <c>for</c> loop in conjunction with the <c>range</c> function.
1515
For example:
1616
</p>
1717

@@ -47,7 +47,7 @@ range(start,stop)
4747
range(start,stop,step)</pre>
4848

4949
<p>
50-
The Java <c>for loop</c> is really analogous to the last option giving you explicit control over the starting, stopping, and stepping in the three clauses inside the parenthesis.
50+
The Java <c>for</c> loop is really analogous to the last option giving you explicit control over the starting, stopping, and stepping in the three clauses inside the parenthesis.
5151
You can think of it this way:
5252
</p>
5353

@@ -69,7 +69,7 @@ for i in range(100, -1, -5):
6969
</program>
7070

7171
<p>
72-
In Java we would write this as:
72+
In Java, we would write this as:
7373
</p>
7474

7575
<program interactive="activecode" language="java">
@@ -85,12 +85,12 @@ public class DefiniteLoopBackward {
8585
</program>
8686

8787
<p>
88-
In Python the for loop can also iterate over any sequence such as a list, a string, or a tuple.
89-
Java also provides a variation of its <c>for loop</c> that provides the same functionality in its so-called for each loop.
88+
In Python, the <c>for</c> loop can also iterate over any sequence such as a list, a string, or a tuple.
89+
Java also provides a variation of its <c>for</c> loop that provides the same functionality in its so-called for each loop.
9090
</p>
9191

9292
<p>
93-
In Python we can iterate over a list as follows:
93+
In Python, we can iterate over a list as follows:
9494
</p>
9595

9696
<program interactive="activecode" language="python">
@@ -168,8 +168,8 @@ public class StringIterationExample {
168168
<section xml:id="indefinite-loops">
169169
<title>Indefinite Loops</title>
170170

171-
<p>
172-
Both Python and Java support the <c>while</c> loop.
171+
<p><idx><c>while</c> loop</idx>
172+
Both Python and Java support the <c>while</c> loop, which continues to execute as long as a condition is true.
173173
Here is a simple example in Python that counts down from 5:
174174
</p>
175175
<program interactive="activecode" language="python">
@@ -198,8 +198,8 @@ public class WhileLoopExample {
198198
</code>
199199
</program>
200200

201-
<p>
202-
Java adds an additional, if seldom used variation of the while loop called the <c>do-while</c> loop.
201+
<p><idx><c>do-while</c> loop</idx>
202+
Java adds an additional, if seldom used variation of the <c>while</c> loop called the <c>do-while</c> loop.
203203
The <c>do-while</c> loop is very similar to <c>while</c> except that the condition is evaluated at the end of the loop rather than the beginning.
204204
This ensures that a loop will be executed at least one time.
205205
Some programmers prefer this loop in some situations because it avoids an additional assignment prior to the loop.

0 commit comments

Comments
 (0)