Code Generation Algorithm With Python