Python code for Pythagorean theorem