Example is from U of T Learning to Program II Coursera course, based on their function design recipe (login req'd). def can_vote(age): """ (int) -> bool Precondition: age >= 0 Return True if and only if a person aged age can vote in Canada. The legal voting age in Canada is 18 years and older. >>> can_vote(0) False >>> can_vote(18) True >>> can_vote(19) True """ return age >= 18 # comment the following out after tests are complete if __name__ == '__main__': import doctest print (doctest.testmod()) |