Skip to content

Commit 39cc534

Browse files
committed
Fix: separator for unittests
1 parent 43c11d1 commit 39cc534

11 files changed

Lines changed: 185 additions & 185 deletions

_sources/Functions/TheAccumulatorPattern.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ The General Accumulator Pattern
151151
you like to add together?'))
152152
thesum = 0
153153
oddnumber = 1
154-
=====
154+
====
155155
for counter in range(n):
156-
=====
156+
====
157157
thesum = thesum + oddnumber
158158
oddnumber = oddnumber + 2
159-
=====
159+
====
160160
print(thesum)
161161

162162
A Variation on the Accumulator Pattern

_sources/Lists/TheAccumulatorPatternwithLists.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ The Accumulator Pattern with Lists
1616
----------------------------------
1717

1818
Remember the :ref:`accumulator pattern <accumulator>`? Many algorithms involving lists make use of
19-
this pattern to process the items in a list and compute a result. In this section, we'll
19+
this pattern to process the items in a list and compute a result. In this section, we'll
2020
explore the use of the accumulator pattern with lists.
2121

2222
Let's take the problem of adding up all of the items in a list. The following program
2323
computes the sum of a list of numbers.
2424

2525
.. activecode:: ac7_10_0
26-
26+
2727
sum = 0
2828
for num in [1, 3, 5, 7, 9]:
2929
sum = sum + num
@@ -42,7 +42,7 @@ Sometimes when we're accumulating, we don't want to add to our accumulator every
4242
Consider, for example, the following program which counts the number of names with more than 3 letters.
4343

4444
.. activecode:: ac7_10_1
45-
45+
4646
long_names = 0
4747
for name in ["Joe", "Sally", "Amy", "Brad"]:
4848
if len(name) > 3:
@@ -53,9 +53,9 @@ Here, we **initialize** the accumulator variable to be zero on line 1.
5353

5454
We **iterate** through the sequence (line 2).
5555

56-
The **update** step happens in two parts. First, we check to see if the name is longer than 3 letters. If
57-
so, then we increment the accumulator variable ``long_names`` (on line 4) by adding one to
58-
it.
56+
The **update** step happens in two parts. First, we check to see if the name is longer than 3 letters. If
57+
so, then we increment the accumulator variable ``long_names`` (on line 4) by adding one to
58+
it.
5959

6060
At the end, we have accumulated the total number of long names.
6161

@@ -70,17 +70,17 @@ We can use conditionals to also count if particular items are in a string or lis
7070
num_vowels += 1
7171
print(num_vowels)
7272

73-
We can also use ``==`` to execute a similar operation. Here, we'll check to see if the character we are iterating over is
74-
an "o". If it is an "o" then we will update our counter.
73+
We can also use ``==`` to execute a similar operation. Here, we'll check to see if the character we are iterating over is
74+
an "o". If it is an "o" then we will update our counter.
7575

7676
.. image:: Figures/accum_o.gif
77-
:alt: a gif that shows code to check that "o" is in the phrase "onomatopoeia".
77+
:alt: a gif that shows code to check that "o" is in the phrase "onomatopoeia".
7878

7979
Accumulating the Max Value
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~
8181

82-
We can also use the accumulation pattern with conditionals to find the maximum or minimum value. Instead of
83-
continuing to build up the accumulator value like we have when counting or finding a sum, we can reassign the
82+
We can also use the accumulation pattern with conditionals to find the maximum or minimum value. Instead of
83+
continuing to build up the accumulator value like we have when counting or finding a sum, we can reassign the
8484
accumulator variable to a different value.
8585

8686
The following example shows how we can get the maximum value from a list of integers.
@@ -96,13 +96,13 @@ The following example shows how we can get the maximum value from a list of inte
9696

9797
Here, we initialize best_num to zero, assuming that there are no negative numbers in the list.
9898

99-
In the for loop, we check to see if the current value of n is greater than the current value of ``best_num``.
100-
If it is, then we want to **update** ``best_num`` so that it now is assigned the higher number. Otherwise, we
99+
In the for loop, we check to see if the current value of n is greater than the current value of ``best_num``.
100+
If it is, then we want to **update** ``best_num`` so that it now is assigned the higher number. Otherwise, we
101101
do nothing and continue the for loop.
102102

103-
You may notice that the current structure could be a problem. If the numbers were all negative what would
104-
happen to our code? What if we were looking for the smallest number but we initialized ``best_num`` with
105-
zero? To get around this issue, we can initialize the accumulator variable using one of the numbers in the
103+
You may notice that the current structure could be a problem. If the numbers were all negative what would
104+
happen to our code? What if we were looking for the smallest number but we initialized ``best_num`` with
105+
zero? To get around this issue, we can initialize the accumulator variable using one of the numbers in the
106106
list.
107107

108108
.. activecode:: ac7_10_4
@@ -114,13 +114,13 @@ list.
114114
best_num = n
115115
print(best_num)
116116

117-
The only thing we changed was the value of ``best_num`` on line 2 so that the value of ``best_num`` is the
117+
The only thing we changed was the value of ``best_num`` on line 2 so that the value of ``best_num`` is the
118118
first element in ``nums``, but the result is still the same!
119119

120120
Accumulating a String Result
121121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122122

123-
The accumulator pattern can be used to convert a list of items to a string.
123+
The accumulator pattern can be used to convert a list of items to a string.
124124

125125
Consider the following program:
126126

@@ -138,7 +138,7 @@ the current contents of ``result`` with the comma separator and a score from the
138138
the ``result`` with the new value. Use CodeLens to step through this example to see it in action.
139139

140140
The output of the program has some undesirable formatting problems: there is a trailing comma instead
141-
of a period, and there are no spaces between the items. The next activity lets you work to
141+
of a period, and there are no spaces between the items. The next activity lets you work to
142142
correct those problems.
143143

144144
.. tabbed:: tab_string_accum
@@ -163,7 +163,7 @@ correct those problems.
163163

164164
print("The scores are " + result)
165165

166-
=====
166+
====
167167

168168
from unittest.gui import TestCaseGui
169169

@@ -254,8 +254,8 @@ correct those problems.
254254
**Challenge** For each word in ``words``, add 'd' to the end of the word if the word ends in "e" to make it past tense. Otherwise, add 'ed' to make it past tense. Save these past tense words to a list called ``past_tense``.
255255
~~~~
256256
words = ["adopt", "bake", "beam", "confide", "grill", "plant", "time", "wave", "wish"]
257-
258-
=====
257+
258+
====
259259

260260
from unittest.gui import TestCaseGui
261261

_sources/PythonTurtle/AFewMoreturtleMethodsandObservations.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,63 +102,63 @@ color, or to put her pen down and draw a line, or to change her shape, etc.)
102102

103103
.. parsonsprob:: 3_10
104104

105-
The following program uses the stamp method to create a circle of turtle shapes as shown to the left:
105+
The following program uses the stamp method to create a circle of turtle shapes as shown to the left:
106106

107-
.. image:: Figures/TurtleCircle.png
107+
.. image:: Figures/TurtleCircle.png
108108
:width: 150
109-
:align: left
110-
109+
:align: left
110+
111111
But the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to "turtle", and pick up the pen. Then the turtle should repeat the following ten times: go forward 50 pixels, leave a copy of the turtle at the current position, reverse for 50 pixels, and then turn right 36 degrees. After the loop, set the window to close when the user clicks in it.
112-
113-
Drag the blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on <i>Check Me</i> to see if you are right. You will be told if any of the lines are in the wrong order or are incorrectly indented.
112+
113+
Drag the blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on <i>Check Me</i> to see if you are right. You will be told if any of the lines are in the wrong order or are incorrectly indented.
114114
-----
115115
import turtle
116116
wn = turtle.Screen()
117117
jose = turtle.Turtle()
118118
jose.shape("turtle")
119119
jose.penup()
120-
=====
121-
for size in range(10):
122-
=====
123-
jose.forward(50)
124120
=====
125-
jose.stamp()
126-
=====
127-
jose.forward(-50)
121+
for size in range(10):
128122
=====
129-
jose.right(36)
123+
jose.forward(50)
124+
====
125+
jose.stamp()
130126
=====
127+
jose.forward(-50)
128+
====
129+
jose.right(36)
130+
====
131131
wn.exitonclick()
132132

133133
**Mixed up program**
134134

135135
.. parsonsprob:: 3_11
136136

137137
The following program uses the stamp method to create a line of turtle shapes as shown to the left:
138-
139-
.. image:: Figures/Turtle3Stamp.png
138+
139+
.. image:: Figures/Turtle3Stamp.png
140140
:width: 150
141-
:align: left
142-
141+
:align: left
142+
143143
But the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to "turtle", and pick up the pen. Then the turtle should repeat the following three times: go forward 50 pixels and leave a copy of the turtle at the current position. After the loop, set the window to close when the user clicks in it.
144-
144+
145145
Drag the blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on <i>Check Me</i> to see if you are right. You will be told if any of the lines are in the wrong order or are incorrectly indented.
146146
-----
147147
import turtle
148148
wn = turtle.Screen()
149-
=====
149+
====
150150
nikea = turtle.Turtle()
151-
=====
151+
====
152152
nikea.shape("turtle")
153-
=====
153+
====
154154
nikea.penup()
155-
=====
156-
for size in range(3):
157-
=====
155+
=====
156+
for size in range(3):
157+
=====
158158
nikea.forward(50)
159+
====
160+
nikea.stamp()
159161
=====
160-
nikea.stamp()
161-
=====
162162
wn.exitonclick()
163163

164164
.. admonition:: Lab

_sources/PythonTurtle/InstancesAHerdofTurtles.rst

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ completes her triangle:
2525
:tour_1: "Overall Tour"; 1-31: Example03_Tour01_Line01; 1-3: Example03_Tour01_Line02; 6-8: Example03_Tour01_Line03; 10: Example03_Tour01_Line04; 6,10: Example03_Tour01_Line05; 12-17: Example03_Tour01_Line06; 19-20: Example03_Tour01_Line07; 22-29: Example03_Tour01_Line08; 31: Example03_Tour01_Line09;
2626
:tour_2: "Line by Line Tour"; 1: Example01_Tour02_Line01; 2: Example01_Tour02_Line02; 3: Example02_Tour02_Line03; 6: Example02_Tour02_Line04; 7: Example03_Tour02_Line05; 8: Example03_Tour02_Line06; 10: Example01_Tour02_Line03; 6,10: Example03_Tour01_Line05; 12-17: Example03_Tour02_Line09; 12-13: Example03_Tour02_Line10; 12: Example03_Tour02_Line11; 13: Example03_Tour02_Line12; 14-15: Example03_Tour02_Line13; 14: Example03_Tour02_Line14; 15: Example03_Tour02_Line15; 16-17: Example03_Tour02_Line16; 16: Example03_Tour02_Line17; 17: Example03_Tour02_Line18; 19-20: Example03_Tour01_Line07; 19: Example03_Tour02_Line20; 20: Example03_Tour02_Line21; 22-29: Example03_Tour01_Line08; 10: Example03_Tour02_Line23; 22-23: Example03_Tour02_Line24; 22: Example03_Tour02_Line25; 23: Example03_Tour02_Line26; 24-25: Example03_Tour02_Line27; 26-27: Example03_Tour02_Line28; 28-29: Example03_Tour02_Line29; 31: Example02_Tour02_Line10;
2727
:nocodelens:
28-
28+
2929
import turtle
3030
wn = turtle.Screen() # Set up the window and its attributes
3131
wn.bgcolor("lightgreen")
@@ -100,63 +100,63 @@ Here are some *How to think like a computer scientist* observations:
100100
.. parsonsprob:: 3_6
101101

102102
The following program has one turtle, "jamal", draw a capital L in blue and then another, "tina", draw a line to the west in orange as shown to the left:
103-
104-
.. image:: Figures/TwoTurtles1.png
103+
104+
.. image:: Figures/TwoTurtles1.png
105105
:width: 150
106-
:align: left
107-
106+
:align: left
107+
108108
The program should do all set-up, have "jamal" draw the L, and then have "tina" draw the line. Finally, it should set the window to close when the user clicks in it.
109-
109+
110110
Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on *Check Me* to see if you are right. You will be told if any of the lines are in the wrong order.
111111
-----
112112
import turtle
113113
wn = turtle.Screen()
114-
=====
114+
=====
115115
jamal = turtle.Turtle()
116116
jamal.pensize(10)
117-
jamal.color("blue")
117+
jamal.color("blue")
118118
jamal.right(90)
119119
jamal.forward(150)
120-
=====
120+
=====
121121
jamal.left(90)
122122
jamal.forward(75)
123-
=====
123+
====
124124
tina = turtle.Turtle()
125125
tina.pensize(10)
126126
tina.color("orange")
127127
tina.left(180)
128128
tina.forward(75)
129-
=====
129+
====
130130
wn.exitonclick()
131131

132132
.. parsonsprob:: 3_7
133133

134134
The following program has one turtle, "jamal", draw a line to the north in blue and then another, "tina", draw a line to the east in orange as shown to the left:
135-
136-
.. image:: Figures/TwoTurtlesL.png
135+
136+
.. image:: Figures/TwoTurtlesL.png
137137
:width: 150
138-
:align: left
139-
138+
:align: left
139+
140140
The program should import the turtle module, get the window to draw on, create the turtle "jamal", have it draw a line to the north, then create the turtle "tina", and have it draw a line to the east. Finally, it should set the window to close when the user clicks in it.
141-
141+
142142
Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on *Check Me* to see if you are right. You will be told if any of the lines are in the wrong order.
143143
-----
144144
import turtle
145-
=====
145+
====
146146
wn = turtle.Screen()
147-
=====
147+
=====
148148
jamal = turtle.Turtle()
149-
jamal.color("blue")
150-
jamal.pensize(10)
151-
=====
149+
jamal.color("blue")
150+
jamal.pensize(10)
151+
=====
152152
jamal.left(90)
153153
jamal.forward(150)
154-
=====
154+
====
155155
tina = turtle.Turtle()
156-
tina.pensize(10)
156+
tina.pensize(10)
157157
tina.color("orange")
158158
tina.forward(150)
159-
=====
159+
====
160160
wn.exitonclick()
161161

162162

0 commit comments

Comments
 (0)