Created
January 19, 2014 19:43
-
-
Save svschannak/8510014 to your computer and use it in GitHub Desktop.
Calculate ratio with Python and Numpy.
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
#calculates r for height and width | |
def ratio(a, b): | |
a = float(a) | |
b = float(b) | |
if b == 0: | |
return a | |
return ratio(b, a % b) | |
#returns a string with ratio for height and width | |
def get_ratio(a, b): | |
r = ratio(a, b) | |
return "%s" % float((a/r) / (b/r)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment