Skip to content

Commit b44da0e

Browse files
committed
Fix: bad update for unittests
1 parent 39cc534 commit b44da0e

23 files changed

Lines changed: 210 additions & 209 deletions

_sources/Dictionaries/Exercises.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Exercises
2222
Write a program that allows the user to enter a string. It then prints a
2323
table of the letters of the alphabet in alphabetical order which occur in
2424
the string together with the number of times each letter occurs. Case should
25-
be ignored. A sample run of the program might look this this::
26-
25+
be ignored. A sample run of the program might look this this::
26+
2727
Please enter a sentence: ThiS is String with Upper and lower case Letters.
2828
a 2
2929
c 1
@@ -43,7 +43,7 @@ Exercises
4343
w 2
4444
$
4545
~~~~
46-
46+
4747
.. tab:: Answer
4848

4949
.. activecode:: de_q1_answer
@@ -79,48 +79,48 @@ Exercises
7979

8080
Give the Python interpreter's response to each of the following from a
8181
continuous interpreter session:
82-
82+
8383
a.
8484
.. sourcecode:: python
85-
85+
8686
>>> d = {'apples': 15, 'bananas': 35, 'grapes': 12}
8787
>>> d['banana']
88-
88+
8989
b.
9090
.. sourcecode:: python
91-
91+
9292
>>> d['oranges'] = 20
9393
>>> len(d)
94-
94+
9595
c.
9696
.. sourcecode:: python
97-
97+
9898
>>> 'grapes' in d
99-
99+
100100
d.
101101
.. sourcecode:: python
102-
102+
103103
>>> d['pears']
104-
104+
105105
e.
106106
.. sourcecode:: python
107-
107+
108108
>>> d.get('pears', 0)
109-
109+
110110
f.
111111
.. sourcecode:: python
112-
112+
113113
>>> fruits = d.keys()
114114
>>> fruits.sort()
115115
>>> print(fruits)
116-
116+
117117
g.
118118
.. sourcecode:: python
119-
119+
120120
>>> del d['apples']
121121
>>> 'apples' in d
122-
123-
122+
123+
124124
Be sure you understand why you get each result. Then apply what you
125125
have learned to fill in the body of the function below, and add code for
126126
the tests indicated:
@@ -153,7 +153,7 @@ Exercises
153153
(You can obtain a free plain text version of the book, along with many others, from
154154
http://www.gutenberg.org.) The first 10 lines of your output file should look
155155
something like this
156-
156+
157157
=========== ===========
158158
Word Count
159159
=========== ===========
@@ -166,10 +166,10 @@ Exercises
166166
absence 1
167167
absurd 2
168168
=========== ===========
169-
169+
170170
How many times does the word, ``alice``, occur in the book? If you are writing this
171171
in the activecode window simply print out the results rather than write them to a file.
172-
~~~~
172+
~~~~
173173

174174
.. tab:: Answer
175175

@@ -234,7 +234,7 @@ Exercises
234234
:autograde: unittest
235235

236236
Here's a table of English to Pirate translations
237-
237+
238238
========== ==============
239239
English Pirate
240240
========== ==============
@@ -257,10 +257,10 @@ Exercises
257257
is be
258258
man matey
259259
========== ==============
260-
261-
Write a function named ``translator`` that takes a parameter containing a sentence in English
260+
261+
Write a function named ``translator`` that takes a parameter containing a sentence in English
262262
(no punctuation and all words in lowercase) and returns that sentence translated to Pirate.
263-
263+
264264
For example, the sentence "hello there students" should be translated to "avast there swabbies".
265265
~~~~
266266
def translator(english):
@@ -276,7 +276,7 @@ Exercises
276276

277277
# Complete the function
278278

279-
====
279+
=====
280280
from unittest.gui import TestCaseGui
281281

282282
class myTests(TestCaseGui):

_sources/Functions/Exercises.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Exercises
232232
def sumTo(n):
233233
# your code here
234234

235-
====
235+
=====
236236
from unittest.gui import TestCaseGui
237237

238238
class myTests(TestCaseGui):
@@ -282,7 +282,7 @@ Exercises
282282
def areaOfCircle(r):
283283
# your code here
284284

285-
====
285+
=====
286286
from unittest.gui import TestCaseGui
287287

288288
class myTests(TestCaseGui):
@@ -404,7 +404,7 @@ Exercises
404404
def sumTo(n):
405405
# your code here
406406

407-
====
407+
=====
408408
from unittest.gui import TestCaseGui
409409
class myTests(TestCaseGui):
410410

@@ -456,7 +456,7 @@ Exercises
456456
def mySqrt(n):
457457
# your code here
458458

459-
====
459+
=====
460460
from unittest.gui import TestCaseGui
461461

462462
class myTests(TestCaseGui):

_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/IntroRecursion/ProgrammingExercises.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Programming Exercises
2323
def computeFactorial(number):
2424
#your code here
2525

26-
====
26+
=====
2727

2828
from unittest.gui import TestCaseGui
2929

@@ -53,7 +53,7 @@ Programming Exercises
5353
#your code here
5454

5555

56-
====
56+
=====
5757

5858
from unittest.gui import TestCaseGui
5959

_sources/Lists/Exercises.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Exercises
4747
.. actex:: ex_9_2
4848
:autograde: unittest
4949

50-
Create a list called ``myList`` with the following six items: 76, 92.3, "hello", True, 4, 76.
50+
Create a list called ``myList`` with the following six items: 76, 92.3, "hello", True, 4, 76.
5151
Begin with the empty list shown below, and add 6 statements to add each item, one per item. The first three statements should
5252
use the append method to append the item to the list, and the last three statements should use concatenation.
5353
~~~~
@@ -56,7 +56,7 @@ Exercises
5656

5757
# Your code here
5858

59-
====
59+
=====
6060
from unittest.gui import TestCaseGui
6161

6262
class myTests(TestCaseGui):
@@ -92,7 +92,7 @@ Exercises
9292
.. actex:: ex_9_3
9393

9494
Starting with the list of the previous exercise, write Python statements to do the following:
95-
95+
9696
a. Append "apple" and 76 to the list.
9797
#. Insert the value "cat" at position 3.
9898
#. Insert the value 99 at the start of the list.
@@ -144,7 +144,7 @@ Exercises
144144
def average(numlist):
145145
# Complete the function definition
146146

147-
====
147+
=====
148148
from unittest.gui import TestCaseGui
149149

150150
class myTests(TestCaseGui):
@@ -165,7 +165,7 @@ Exercises
165165
for num in numlist:
166166
total = total + num
167167

168-
return total / len(numlist)
168+
return total / len(numlist)
169169

170170

171171
.. question:: strings_ex_5
@@ -183,7 +183,7 @@ Exercises
183183
def max(lst):
184184
# Complete the function
185185

186-
====
186+
=====
187187
from unittest.gui import TestCaseGui
188188

189189
class myTests(TestCaseGui):
@@ -223,11 +223,11 @@ Exercises
223223
Write a function ``sum_of_squares(xs)`` that computes the sum
224224
of the squares of the numbers in the list ``xs``. For example,
225225
``sum_of_squares([2, 3, 4])`` should return 4+9+16 which is 29:
226-
~~~~
226+
~~~~
227227
def sum_of_squares(xs):
228228
# your code here
229229

230-
====
230+
=====
231231
from unittest.gui import TestCaseGui
232232

233233
class myTests(TestCaseGui):
@@ -254,7 +254,7 @@ Exercises
254254
def countOdd(lst):
255255
# your code here
256256

257-
====
257+
=====
258258
from unittest.gui import TestCaseGui
259259

260260
class myTests(TestCaseGui):
@@ -307,7 +307,7 @@ Exercises
307307
def sumEven(lst):
308308
# your code here
309309

310-
====
310+
=====
311311
from unittest.gui import TestCaseGui
312312

313313
class myTests(TestCaseGui):
@@ -335,7 +335,7 @@ Exercises
335335
def sumNegatives(lst):
336336
# your code here
337337

338-
====
338+
=====
339339
from unittest.gui import TestCaseGui
340340

341341
class myTests(TestCaseGui):
@@ -401,7 +401,7 @@ Exercises
401401
def sumUntilEven(lst):
402402
# your code here
403403

404-
====
404+
=====
405405
from unittest.gui import TestCaseGui
406406

407407
class myTests(TestCaseGui):
@@ -461,13 +461,13 @@ Exercises
461461
.. actex:: ex_9_12
462462

463463
Although Python provides us with many list methods, it is good practice and very instructive to think about how they are implemented. Implement a Python function that works like the following:
464-
464+
465465
a. count
466466
#. in
467467
#. reverse
468468
#. index
469469
#. insert
470-
~~~~
470+
~~~~
471471

472472
.. tab:: Answer
473473

@@ -528,22 +528,22 @@ Exercises
528528

529529
Write a function ``replace(s, old, new)`` that replaces all occurences of
530530
``old`` with ``new`` in a string ``s``::
531-
531+
532532
test(replace('Mississippi', 'i', 'I'), 'MIssIssIppI')
533-
533+
534534
s = 'I love spom! Spom is my favorite food. Spom, spom, spom, yum!'
535535
test(replace(s, 'om', 'am'),
536536
'I love spam! Spam is my favorite food. Spam, spam, spam, yum!')
537-
537+
538538
test(replace(s, 'o', 'a'),
539539
'I lave spam! Spam is my favarite faad. Spam, spam, spam, yum!')
540-
540+
541541
*Hint*: use the ``split`` and ``join`` methods.
542542
~~~~
543543
def replace(s, old, new):
544544
# your code here
545545

546-
====
546+
=====
547547
from unittest.gui import TestCaseGui
548548

549549
class myTests(TestCaseGui):
@@ -569,9 +569,9 @@ Exercises
569569
Here are the rules for an L-system that creates something that resembles
570570
a common garden herb. Implement the following rules and try it. Use an
571571
angle of 25.7 degrees.
572-
572+
573573
::
574-
574+
575575
H
576576
H --> HFX[+H][-H]
577577
X --> X[-FFF][+FFF]FX
@@ -660,12 +660,12 @@ Exercises
660660
:nocodelens:
661661

662662
Here is another L-System. Use an Angle of 25.
663-
663+
664664
::
665-
665+
666666
F
667667
F --> F[-F]F[+F]F
668-
~~~~
668+
~~~~
669669

670670
.. question:: strings_ex_17
671671

@@ -676,10 +676,10 @@ Exercises
676676
.. actex:: ex_9_17
677677
:autograde: unittest
678678

679-
Create a list named ``randlist`` containing 100 random integers between 0 and 1000 (use iteration, append, and the random module).
679+
Create a list named ``randlist`` containing 100 random integers between 0 and 1000 (use iteration, append, and the random module).
680680
~~~~
681681

682-
====
682+
=====
683683
from unittest.gui import TestCaseGui
684684

685685
class myTests(TestCaseGui):

0 commit comments

Comments
 (0)