#!/usr/bin/python
#
# Example showing how to use doctest
# including two useful modifiers: ELLIPSIS and WHITESPACE
#
def minmax( x ):
"""
This function finds the min and max values in the array x
>>> minmax([1,3,3,5])
(1, 5)
>>> minmax([2,1])
(1, 2)
"""
return (min(x), max(x))
def squares( a , b ):
"""
returns all the squares in range a..b
>>> squares( 1 , 10 ) # doctest:+ELLIPSIS +NORMALIZE_WHITESPACE
[1, 4, ..., 100]
"""
answer=[]
for i in range(a,b+1):
answer.append(i*i)
return answer
if __name__ == '__main__':
import doctest
verbose=1
if(verbose):
doctest.testmod(None,None,None,True)
else:
doctest.testmod()
|