Skip to content

Instantly share code, notes, and snippets.

@minte9
Last active July 16, 2021 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minte9/9e15623532be8bc01dfca94efa82625d to your computer and use it in GitHub Desktop.
Save minte9/9e15623532be8bc01dfca94efa82625d to your computer and use it in GitHub Desktop.
Python / Language / Incremental development - https://www.minte9.com/python/math-development-1257
# Use incremental development to write a function called hypotenuse
# The function returns the length of the hypotenuse of a right triangle
# The function gets the other two legs as arguments
# Record each stage of the development
# SOLUTION
# v1.0 --------------------------
def hypotenuse(a, b):
return 0
print (hypotenuse(3,4)) # 0
# v2.0 -------------------------
def hypotenuse(a, b):
sum = a**2 + b**2
return sum
print(hypotenuse(3, 4)) # 25
# v3.0 -------------------------
import math
def hypotenuse(a, b):
sum = a**2 + b**2
return math.sqrt(sum)
print(hypotenuse(3, 4)) # 5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment