Python code on some interesting problems