Skip to content

Commit

Permalink
Merge pull request keon#14 from stongaf/master
Browse files Browse the repository at this point in the history
added pythagoras.py to maths
  • Loading branch information
keon authored Apr 24, 2017
2 parents 8061b28 + 1fee342 commit 0ef4b74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ List of Implementations:
│   ├── generate_strobogrammtic.py
│   ├── is_strobogrammatic.py
│   ├── nth_digit.py
│   └── sqrt_precision_factor.py
│   ├── sqrt_precision_factor.py
│   └── pythagoras.py
├── matrix
│   ├── bomb_enemy.py
│   ├── matrix_rotation.txt
Expand Down
16 changes: 16 additions & 0 deletions math/pythagoras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
input two of the three side in right angled triangle and return the third. use "?" to indicate the unknown side.
"""

def pythagoras(opposite,adjacent,hypotenuse):
try:
if opposite == str("?"):
return ("Opposite = " + str(((hypotenuse**2) - (adjacent**2))**0.5))
elif adjacent == str("?"):
return ("Adjacent = " + str(((hypotenuse**2) - (opposite**2))**0.5))
elif hypotenuse == str("?"):
return ("Hypotenuse = " + str(((opposite**2) + (adjacent**2))**0.5))
else:
return "You already know the answer!"
except:
print ("Error, check your input. You must know 2 of the 3 variables.")

0 comments on commit 0ef4b74

Please sign in to comment.