Skip to content

Commit 92597b4

Browse files
restuctured exceptions and series exercises
1 parent 5ffb64f commit 92597b4

13 files changed

Lines changed: 38 additions & 34 deletions

File tree

‎source/class_schedule/lesson02.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Exercises:
2626

2727
../exercises/grid_printer.rst
2828
../exercises/fizz_buzz.rst
29-
../exercises/fib_and_lucas.rst
29+
../exercises/series/fib_and_lucas.rst
3030

3131

3232
Python

‎source/class_schedule/lesson04.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Exercises:
3434
.. toctree::
3535
:maxdepth: 1
3636

37-
../exercises/exceptions_lab.rst
38-
../exercises/except_exercise.rst
37+
../exercises/exceptions/exceptions_lab.rst
38+
../exercises/exceptions/except_exercise.rst
3939
../exercises/unit_testing/unit_testing.rst
4040
../exercises/dict_lab.rst
4141
../exercises/mailroom/mailroom_with_dicts.rst

‎source/class_schedule/lesson05.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Exercises:
2525
:maxdepth: 1
2626

2727
../exercises/file_processing/file_lab.rst
28-
../exercises/exceptions_lab.rst
29-
../exercises/except_exercise.rst
28+
../exercises/exceptions/exceptions_lab.rst
29+
../exercises/exceptions/except_exercise.rst
3030
../exercises/comprehensions_lab.rst
3131
../exercises/mailroom/mailroom_with_exceptions.rst
3232
../exercises/mailroom/mailroom_with_files.rst

‎source/class_schedule/lesson07.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ Exercises:
7070
:maxdepth: 1
7171

7272
../exercises/oo_intro/oo_intro.rst
73-
../exercises/html_renderer.rst
74-
../exercises/html_renderer_tutorial.rst
73+
../exercises/html_renderer/html_renderer.rst
74+
../exercises/html_renderer/html_renderer_tutorial.rst
File renamed without changes.

source/exercises/except_exercise.rst renamed to source/exercises/exceptions/except_exercise.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This is a little exercise that shows you how to handle exceptions in a way that
99
Procedure
1010
=========
1111

12-
Here are two files that you should put in your ``lesson05`` directory in the class repo.
12+
Here are two files that you should be in the github classroom repo:
1313

1414
:download:`except_exercise.py`
1515

@@ -23,8 +23,8 @@ Run ``except_exercise.py``::
2323

2424
You will find that it crashes with an exception.
2525

26-
Your job is to write the proper exception handler in the except_exercise.py
27-
code, so that the code can run.
26+
Your job is to write the proper exception handler in the
27+
``except_exercise.py`` file, so that the code can run.
2828

2929
It will then crash again.
3030

@@ -61,7 +61,7 @@ In this case, that's line 17 of ``except_exercise.py``. In real life, it can be
6161
Results
6262
-------
6363

64-
When you are done, running except_exercise.py should result in output something like this::
64+
When you are done, running ``except_exercise.py`` should result in output something like this::
6565

6666
Spam, Spam, Spam, Spam, Beautiful Spam
6767

@@ -75,4 +75,5 @@ When you are done, running except_exercise.py should result in output something
7575
Why are you doing this?
7676
-----------------------
7777

78-
This is a kind of silly exercise, but in real life, this is a common workflow -- you call a library, and find that in certain circumstances it raises an exception. As the code in the library is out of your hands, you need to decide how to handle that exception in your code instead.
78+
This is a kind of silly exercise, but in real life, this is a common work flow -- you call a library, and find that in certain circumstances it raises an exception.
79+
As the code in the library is out of your hands, you need to decide how to handle that exception in your code instead.
File renamed without changes.
File renamed without changes.
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ Fibonacci Series Exercise
77
Computing the Fibonacci and Lucas Series
88
========================================
99

10+
Some nifty uses of recursion
11+
1012
Goal:
1113
-----
1214

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

1517
In this series, the next integer is determined by summing the previous two
1618

17-
1819
This gives us::
1920

2021
0, 1, 1, 2, 3, 5, 8, 13, ...
@@ -25,20 +26,21 @@ We will write a function that computes this series -- then generalize it.
2526

2627
.. _Fibonacci Series: http://en.wikipedia.org/wiki/Fibbonaci_Series
2728

29+
2830
Step 1
2931
------
3032

31-
* Create a new module ``series.py`` in the ``lesson02`` folder in your student folder.
33+
* Create a new file ``series.py`` in the exercise repo.
3234

3335
- In it, add a function called ``fibonacci``.
3436

3537
- The function should have one parameter ``n``.
3638

37-
- The function should return the ``nth`` value in the fibonacci series (starting with zero index).
39+
- The function should return the ``nth`` value in the Fibonacci series (starting with zero index).
3840

39-
* Ensure that your function has a well-formed ``docstring``
41+
* Ensure that your function has a well-formed "docstring"
4042

41-
Note that the fibonacci series is naturally recursive -- the value is
43+
Note that the Fibonacci series is naturally recursive -- the value is
4244
defined by previous values:
4345

4446
fib(n) = fib(n-2) + fib(n-1)
@@ -55,19 +57,20 @@ values 2 and 1 rather than 0 and 1. The resulting series looks like this::
5557
.. _Lucas Numbers: http://en.wikipedia.org/wiki/Lucas_number
5658

5759

58-
In your ``series.py`` module, add a new function ``lucas`` that returns the
59-
``nth`` value in the *lucas numbers* series (starting with zero index).
60+
In your ``series.py`` file, add a new function ``lucas`` that returns the
61+
``nth`` value in the *Lucas numbers* series (starting with zero index).
6062

61-
Ensure that your function has a well-formed ``docstring``
63+
Ensure that your function has a well-formed "docstring"
64+
65+
You should find it's *very* similar to the ``fibonacci()`` function.
6266

63-
YOu should find it's *very* similar to the ``fibonacci()`` function.
6467

6568
Generalizing
6669
------------
6770

6871
Both the *fibonacci series* and the *lucas numbers* are based on an identical formula:
6972

70-
fib(n) = fib(n-2) + fib(n-1)
73+
f(n) = f(n-2) + f(n-1)
7174

7275
That's why the code is so similar.
7376

@@ -80,10 +83,9 @@ The required parameter will determine which element in the
8083
series to print.
8184
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.
8285

83-
Calling this function with no optional parameters will produce numbers from the *fibonacci series* (because 0 and 1 are the defaults).
86+
Calling this function with no optional parameters will produce numbers from the *Fibonacci series* (because 0 and 1 are the defaults).
8487

85-
Calling it with the optional arguments 2 and 1 will
86-
produce values from the *lucas numbers*.
88+
Calling it with the optional arguments 2 and 1 will produce values from the *Lucas numbers*.
8789

8890
Other values for the optional parameters will produce other series.
8991

@@ -92,10 +94,11 @@ of the functions you wrote, the idea of this exercise is to make a general
9294
function, rather than one specialized. So you should re-implement the code
9395
in this function.
9496

95-
In fact, you could go back and re-implement your fibonacci and lucas
97+
In fact, you could go back and re-implement your Fibonacci and Lucas
9698
functions to call ``sum-series`` with particular arguments.
9799

98-
Ensure that your function has a well-formed ``docstring``
100+
Ensure that your function has a well-formed "docstring"
101+
99102

100103
Tests...
101104
--------
@@ -108,10 +111,10 @@ Use comments in this block to inform the observer what your tests do.
108111

109112
We have created a template for you to use to clarify what we mean by these asserts:
110113

111-
:download:`series_template.py <../exercises/series_template.py>`
114+
:download:`series_template.py <./series_template.py>`
112115

113116
Add your new module to your personal git repo and commit frequently while working on your implementation.
114117
Include good commit messages that explain concisely both *what* you are doing and *why*.
115118

116-
When you are finished, push your changes to your fork of the class repository in GitHub and make a pull request.
119+
When you are finished, push your changes to your fork of exercise repository in GitHub and make a pull request to submit it.
117120

File renamed without changes.

0 commit comments

Comments
 (0)