Checkpoint 5.2.10. A Python program, including another.
View Source for exercise
<exercise xml:id="exercise-python-including">
<title>A Python program, including another</title>
<statement>
<p>Compute the total amount of money loaned and store it in the variable <c>loan_total</c>.</p>
</statement>
<program autorun="yes" codelens="no" xml:id="python-summation" interactive="activecode" language="python" label="python-sum-total" include="python-statistics">
<code>
loan_total = 0
for loan in loan_amount:
loan_total += loan
print(loan_total)
</code>
<tests>
from unittest.gui import TestCaseGui
class MyTests(TestCaseGui):
def testOne(self):
self.assertTrue('loan_total' in self.getEditorText(), "you need a loan_total variable")
self.assertEqual(loan_total, sum(loan_amount), "Use the accumulator pattern to add up all the loans")
self.assertFalse('sum(' in self.getEditorText(), "you may not use sum()")
MyTests().main()
</tests>
</program>
</exercise>
Compute the total amount of money loaned and store it in the variable
loan_total
.