author | Madhusudan.C.S <madhusudancs@gmail.com> |
Tue, 07 Sep 2010 14:29:48 +0530 | |
changeset 127 | f65aec952da7 |
parent 126 | b9c6563869ef |
child 128 | 29e6b1d5e5f5 |
permissions | -rw-r--r-- |
126
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
====================================== |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
Lab Workbook - Test Driven Development |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
====================================== |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
The notation that follows every question denotes the level on the |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
Revised Bloom's Taxonomy. |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
Lab - 1 |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
======= |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
1. Write a stub function for calculating the LCM of two numbers. |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
2. Write the tests for the LCM function, place the tests in if |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
__name__ == '__main__': part of the Python file. Demonstrate that |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
the tests fail. |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
3. Implement the code for the LCM function, using the gcd function |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
provided in the examples in the chapter. Demonstrate the tests |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
pass. (For the algorithm refer to Wikipedia - [0]) |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
4. Alternatively, build a set of test cases, preferably a large |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
number of cases, place it in a text file and use these test cases |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
to test your LCM function. Demonstrate that tests still continue |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
to pass. |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
[0] - http://en.wikipedia.org/wiki/Least_common_multiple#Reduction_by_the_greatest_common_divisor |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
Lab - 2 |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
======= |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
|
127
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
28 |
1. Write the stub function, followed by the tests(demonstrating the |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
29 |
failed tests), in turn followed by the code(demonstrating the |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
30 |
passing tests) to calculate the number of days between two |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
31 |
dates. Name your function num_of_days(). The function should take |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
32 |
two arguments, both being tuples. Each tuple represents the date |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
33 |
in the format of (dd, mm, yyyy) where dd, mm and yyyy are |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
34 |
integers. |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
35 |
2. Rewrite the num_of_days() function to take the start date as an |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
36 |
optional argument. If the start date is not specified calculate |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
37 |
the number of days between the only specified date since Unix |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
38 |
epoch. Prior to manipulating the code to do this, make sure you |
f65aec952da7
Add second lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
39 |
change the tests, make them fail and then refactor the code. |
126
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
Lab -3 |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
====== |
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
|
b9c6563869ef
First Lab exercise questions. Sorry for very small commits. I paid the penalty of losing my entire file on which I had worked on 1 and half days.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
1. |