Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pythogrean Theorem calculator in Python 3
- # Usage in command line: python pythagorean.py <num1> <num2> <num3> ...
- import sys
- from math import sqrt
- args = sys.argv[1:]
- numbers = []
- for num in args:
- numbers.append(float(num) ** 2)
- pyt = sqrt(sum(numbers))
- print("{:.3f}".format(pyt))
- # Batch file:
- # To type "pyt <num1> <num2> <num3> ..." instead of the longer version:
- # Place file "pyt.bat" (or any short name) in PATH or "C:\Users\<Current User>\"
- # python "<Path>\pythagorean.py" %*
- #
- # Note: Replace <Path> with the path of this file
- # pythagorean.py should be the name of the Python script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement