Created
October 9, 2012 21:51
-
-
Save Tyaedalis/3861681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def strToNum(string): | |
if '/' in string: | |
num, den = string.split('/') | |
return int(num)/int(den) | |
elif '.' in string: | |
return float(string) | |
else: return int(string) | |
run = 1 | |
while run: | |
coords = [] | |
for x in range(2): | |
coords.append(input("coord {}: ".format(x+1)).split()) | |
for pair in coords: | |
for value in pair: | |
value = strToNum(value) | |
print(pair) | |
x1, y1 = coords[0][0], coords[0][1] | |
x2, y2 = coords[-1][0], coords[-1][1] | |
delta_y = y2 - y1 | |
delta_x = x2 - x1 | |
print() | |
print("∆y = {} - {} = {}".format(y2, y1, delta_y)) | |
print("∆x = {} - {} = {}".format(x2, x1, delta_x)) | |
print("m = {}/{} ≈ {}".format(delta_y, delta_x, delta_y/delta_x)) | |
print() | |
if input("Another? (y/n): ") is not 'y': | |
run = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment