- Describe the Problem
As a user So that I can manage my time I want to see an estimate of reading time for a text, assuming that I can read 200 words a minute.
- Design the Function Signature Include the name of the function, its parameters, return value, and side effects.
def reading_time(text):
'The estimated reading time is: ' -->- Create Examples as Tests Make a list of examples of what the function will take and return. -->
Give a text and return esimated reading time
reading_time('text') -> 'The estimated reading time is 1 minute' reading_time('...200...) -> 1.0 reading_time('...400...) -> 2.0 reading_time('...300...) -> 1.5 reading_time('') -> Raises an error 'Empty text'
- Implement the Behaviour After each test you write, follow the test-driving process of red, green, refactor to implement the behaviour.
Here's an example for you to start with:
from lib.reading_time import *
def test_reading_time_returns_one(): result = reading_time(text) assert result == 'The estimated reading time is 1 minute'
def test_reading_time_returns_twentytwo(): result = reading_time(text) assert result == 'The estimated reading time is 22 minutes'