Skip to content

Commit 12bc4d1

Browse files
author
Rick Riehle
committed
Merge branch 'master' into rriehle-2016a-prep
2 parents 96bd485 + 481f3f1 commit 12bc4d1

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

slides_sources/source/exercises/fib_and_lucas.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ We will write a function that computes this series -- then generalize it.
2222

2323
.. _Fibonacci Series: http://en.wikipedia.org/wiki/Fibbonaci_Series
2424

25+
2526
Step 1
2627
------
2728

@@ -57,6 +58,7 @@ In your ``series.py`` module, add a new function ``lucas`` that returns the
5758

5859
Ensure that your function has a well-formed ``docstring``
5960

61+
6062
Generalizing
6163
------------
6264

@@ -75,8 +77,35 @@ parameters will produce other series.
7577

7678
Ensure that your function has a well-formed ``docstring``
7779

78-
Tests...
79-
--------
80+
81+
assert
82+
------
83+
84+
Writing ``tests`` that demonstrate that your program works is an important part of learning to program.
85+
86+
The python ``assert`` statement is useful in writing simple tests
87+
for your code.
88+
89+
.. code-block:: ipython
90+
91+
In [1]: def add(n1, n2):
92+
...: return n1 + n2
93+
...:
94+
95+
In [2]: assert add(3, 4) == 7
96+
97+
In [3]: assert add(3, 4) == 10
98+
99+
---------------------------------------------------------------------
100+
AssertionError Traceback (most recent call last)
101+
<ipython-input-3-6731d4ac4476> in <module>()
102+
----> 1 assert add(3, 4) == 10
103+
104+
AssertionError:
105+
106+
107+
Tests
108+
-----
80109

81110
Add a block of code to the end of your ``series.py``
82111
module. Use the block to write a series of ``assert`` statements that
@@ -91,3 +120,5 @@ your implementation. Include good commit messages that explain concisely both
91120
When you are finished, push your changes to your fork of the class repository
92121
in GitHub and make a pull request.
93122

123+
124+

0 commit comments

Comments
 (0)