tdd/lab-workbook.rst
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 07 Sep 2010 15:16:40 +0530
changeset 128 29e6b1d5e5f5
parent 127 f65aec952da7
child 129 6e237b9442cd
permissions -rw-r--r--
Add third lab exercise questions.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
128
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    45
  1. Move the tests that were written to GCD function in the examples
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    46
     of this chapter to a separate function called test_gcd(). Do the
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    47
     same for LCM function and num_of_days() function. Make sure when
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    48
     the respective Python files are executed as stand alone scripts
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    49
     these tests executed.
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    50
  2. Put all these files in a single directory called utils and run
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    51
     the nosetests command. Make a report of the results.
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    52
  3. Write doctests to each of the above functions. Demonstrate and
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    53
     report the results as executed by running the doctests using
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    54
     doctest.testmod() function and using nosetests command.
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    55
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    56
Lab - 4
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    57
=======
29e6b1d5e5f5 Add third lab exercise questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 127
diff changeset
    58
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
    59
  1.