Update calculate.py

Fixed possible if errors