Skip to content

Commit e65f465

Browse files
committed
Fixes and synch
1 parent 0ce050b commit e65f465

2 files changed

Lines changed: 14 additions & 18 deletions

File tree

_sources/functions/funcWithListsAndLoops.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ the built-in ``range`` function to do this.
330330
# function call
331331
main()
332332

333+
.. note::
334+
335+
The function ``range(start, end, by)`` will return a range object (an iterator) that allows you to loop from ``start`` (inclusive) to ``end`` (exclusive) and add the value of ``by`` after each execution of the loop.
336+
333337
.. parsonsprob:: flal_pp_total_at_odd_indices
334338
:numbered: left
335339
:adaptive:

pretext/functions/funcWithListsAndLoops.ptx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ print(list_get(l))
116116
<p>This would be true if it was returning the item at index 3 or -1.</p>
117117
</feedback>
118118
</choice>
119-
<choice>
120-
<statement>
121-
<p>Nothing, there will be an error.</p>
122-
</statement>
123-
<feedback>
124-
<p>This code will run without any errors.</p>
125-
</feedback>
126-
</choice>
127119
</choices>
128120
</exercise>
129121

@@ -155,7 +147,7 @@ main()
155147
</input>
156148
</program>
157149
</exercise>
158-
150+
159151
<exercise label="flal_ac_sum_first_half">
160152
<statement>
161153
<p>Write a function <c>sum_first_half</c> that takes a list and returns a the sum of just the first half of the items.
@@ -168,17 +160,17 @@ def sum_first_half(alist):
168160
====
169161
from unittest.gui import TestCaseGui
170162

171-
class myTests(TestCaseGui):
163+
class myTests(TestCaseGui):
172164

173-
def testOne(self):
174-
self.assertEqual(sum_first_half([1,2,3,4]), 3, 'sum_first_half([1,2,3,4])')
175-
self.assertEqual(sum_first_half([7,8,9]), 7, 'sum_first_half([7,8,9])')
176-
self.assertEqual(sum_first_half([]), 0, 'sum_first_half([])')
177-
self.assertEqual(sum_first_half([6]), 0, 'sum_first_half([6])')
178-
self.assertEqual(sum_first_half([1,2,3,4,5]), 3, 'sum_first_half([1,2,3,4,5])')
179-
self.assertEqual(sum_first_half([1,2,3,4,5,6]), 6, 'sum_first_half([1,2,3,4,5,6])')
165+
def testOne(self):
166+
self.assertEqual(sum_first_half([1,2,3,4]), 3, 'sum_first_half([1,2,3,4])')
167+
self.assertEqual(sum_first_half([7,8,9]), 7, 'sum_first_half([7,8,9])')
168+
self.assertEqual(sum_first_half([]), 0, 'sum_first_half([])')
169+
self.assertEqual(sum_first_half([6]), 0, 'sum_first_half([6])')
170+
self.assertEqual(sum_first_half([1,2,3,4,5]), 3, 'sum_first_half([1,2,3,4,5])')
171+
self.assertEqual(sum_first_half([1,2,3,4,5,6]), 6, 'sum_first_half([1,2,3,4,5,6])')
180172

181-
myTests().main()
173+
myTests().main()
182174
</input>
183175
</program>
184176
</exercise>

0 commit comments

Comments
 (0)