Skip to content
ufraan
← Back

Odd Even Generator

Generates an absurdly long Python if–elif chain to determine odd or even up to a chosen limit.

CProject
Apr 2026GitHub

This one is pure absurdity on purpose. I wrote a project in C that generates valid but completely unhinged Python code. It produces an if-elif-else chain that checks whether a number is odd or even, with one branch per number, up to a limit you choose. You give it a number like 1000 and it outputs a Python script with 1000 if/elif branches, each checking x equals N and printing whether that specific number is odd or even.

Generated Python if-elif chain output
Generated Python if-elif chain output

The program is pure C with no dependencies, taking a command-line argument for the upper limit and writing directly to stdout. It uses printf to emit Python syntax, handling indentation and line breaks to produce clean, runnable output, all fitting in a single source file.