Learning Game Programming
Tuesday, February 22, 2011
Feb 22
This is the fixed hypotenuse program:
def hypotenuse(a, b):
"""
>>> hypotenuse(3, 4)
5.0
>>> hypotenuse(12, 5)
13.0
>>> hypotenuse(7, 24)
25.0
>>> hypotenuse(9, 12)
15.0
"""
return ((a**2) + (b**2))**0.5
if __name__== '__main__':
import doctest
doctest.testmod()
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment