Created
March 10, 2017 00:48
-
-
Save fiorix/b8a3f0ef56af9fd902b879b21c177896 to your computer and use it in GitHub Desktop.
Percentage Difference Calculator
This file contains hidden or 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
#!/usr/bin/env python | |
# Implementation of http://www.calculatorsoup.com/calculators/algebra/percent-difference-calculator.php | |
v1=5067 | |
v2=5733 | |
def diff(v1, v2): | |
f1, f2 = float(v1), float(v2) | |
v = 1 - ((f1 - f2) / ((f1 + f2) / 2) * 100) - 1 | |
return v | |
print diff(v1, v2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment