PyDoc Demo

"""

PyDoc demo

Use with "-v" option to see test details.

"""

def squared(n):

""" (number) -> number

Precondition: n is a number

Return n squared. If a float, round to one decimal place.

>>> squared(-2)

4

>>> squared(2)

4

>>> squared(1.2)

1.4

>>> squared(0.0)

0.0

>>> squared(0)

0

"""

n = n*n

if type(n) == float:

return round(n,1)

else:

return n

# comment the following out after tests are complete

if __name__ == '__main__':

import doctest

print (doctest.testmod())