Write a python script of the above pseudo code