Python code for math problems