Python code for Physics problems