add python implementation in ex 1