Skip to content

Commit 46c8594

Browse files
committed
clarifications on the sum_series assignment
1 parent c9c3ebf commit 46c8594

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

source/exercises/fib_and_lucas.rst

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ Goal:
1212

1313
The `Fibonacci Series`_ is a numeric series starting with the integers 0 and 1.
1414

15-
In this series, the next integer is determined by summing the previous two.
15+
In this series, the next integer is determined by summing the previous two
16+
1617

1718
This gives us::
1819

1920
0, 1, 1, 2, 3, 5, 8, 13, ...
2021

22+
.. note: 0+1 is 1; 1+1 is 2; 1+2 is 3; 2+3 is 5; 3+5 is 8; and so on forever...
23+
2124
We will write a function that computes this series -- then generalize it.
2225

2326
.. _Fibonacci Series: http://en.wikipedia.org/wiki/Fibbonaci_Series
@@ -31,12 +34,11 @@ Step 1
3134

3235
- The function should have one parameter ``n``.
3336

34-
- The function should return the ``nth`` value in the fibonacci series
35-
(starting with zero index).
37+
- The function should return the ``nth`` value in the fibonacci series (starting with zero index).
3638

3739
* Ensure that your function has a well-formed ``docstring``
3840

39-
Note that the fibinacci series is naturally recursive -- the value is
41+
Note that the fibonacci series is naturally recursive -- the value is
4042
defined by previous values:
4143

4244
fib(n) = fib(n-2) + fib(n-1)
@@ -58,50 +60,58 @@ In your ``series.py`` module, add a new function ``lucas`` that returns the
5860

5961
Ensure that your function has a well-formed ``docstring``
6062

63+
YOu should find it's *very* similar to the ``fibonacci()`` function.
64+
6165
Generalizing
6266
------------
6367

64-
Both the *fibonacci series* and the *lucas numbers* are based on an identical
65-
formula.
68+
Both the *fibonacci series* and the *lucas numbers* are based on an identical formula:
69+
70+
fib(n) = fib(n-2) + fib(n-1)
71+
72+
That's why the code is so similar.
73+
74+
This formula creates a class of series that are all related -- each with a different two starting numbers.
75+
76+
Add a third function called ``sum_series`` that can compute all of these related series.
77+
78+
It should have one required parameter and two optional parameters.
79+
The required parameter will determine which element in the
80+
series to print.
81+
The two optional parameters will have default values of 0 and 1 and will determine the first two values for the series to be produced.
82+
83+
Calling this function with no optional parameters will produce numbers from the *fibonacci series* (because 0 and 1 are the defaults).
6684

67-
Add a third function called ``sum_series`` with one required parameter and two
68-
optional parameters. The required parameter will determine which element in the
69-
series to print. The two optional parameters will have default values of 0 and
70-
1 and will determine the first two values for the series to be produced.
85+
Calling it with the optional arguments 2 and 1 will
86+
produce values from the *lucas numbers*.
7187

72-
Calling this function with no optional parameters will produce numbers from the
73-
*fibonacci series*. Calling it with the optional arguments 2 and 1 will
74-
produce values from the *lucas numbers*. Other values for the optional
75-
parameters will produce other series.
88+
Other values for the optional parameters will produce other series.
7689

7790
**Note:** While you *could* check the input arguments, and then call one
7891
of the functions you wrote, the idea of this exercise is to make a general
79-
function, rather than one specialized. So you should reimplement the code
92+
function, rather than one specialized. So you should re-implement the code
8093
in this function.
8194

82-
In fact, you could go back and reimplement your fibonacci and lucas
83-
functions to call this one with particular arguments.
95+
In fact, you could go back and re-implement your fibonacci and lucas
96+
functions to call ``sum-series`` with particular arguments.
8497

8598
Ensure that your function has a well-formed ``docstring``
8699

87100
Tests...
88101
--------
89102

90-
Add a block of code to the end of your ``series.py``
91-
module. Use the block to write a series of ``assert`` statements that
103+
Add a block of code to the end of your ``series.py`` module.
104+
Use the block to write a series of ``assert`` statements that
92105
demonstrate that your three functions work properly.
93106

94107
Use comments in this block to inform the observer what your tests do.
95108

96-
We have created a template for you to use, to clarify what we mean by these
97-
tests:
109+
We have created a template for you to use to clarify what we mean by these asserts:
98110

99111
:download:`series_template.py <../exercises/series_template.py>`
100112

101-
Add your new module to your git clone and commit frequently while working on
102-
your implementation. Include good commit messages that explain concisely both
103-
*what* you are doing and *why*.
113+
Add your new module to your personal git repo and commit frequently while working on your implementation.
114+
Include good commit messages that explain concisely both *what* you are doing and *why*.
104115

105-
When you are finished, push your changes to your fork of the class repository
106-
in GitHub and make a pull request.
116+
When you are finished, push your changes to your fork of the class repository in GitHub and make a pull request.
107117

source/solutions/Lesson02/print_grid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
def print_grid_trivial():
1515
"""
1616
Did anyone come up with the most trivial possible solution?
17+
18+
Note that this may the the wy to go, oif this all you need to do:
19+
print something specific once. Why write fancy code for that?
1720
"""
1821
print("""
1922
+ - - - - + - - - - +

0 commit comments

Comments
 (0)