Skip to content

Instantly share code, notes, and snippets.

@fiorix
Created March 10, 2017 00:48
Show Gist options
  • Save fiorix/b8a3f0ef56af9fd902b879b21c177896 to your computer and use it in GitHub Desktop.
Save fiorix/b8a3f0ef56af9fd902b879b21c177896 to your computer and use it in GitHub Desktop.
Percentage Difference Calculator
#!/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