refactor function tip-calc.py