Can Somebody Help Me With This Algorithm In Python

Can Somebody Help Me With This Algorithm In Python