Python Calculations With Variable Valve