← Go Back

How to Run Python Code Without a Script

Passing the -c option followed by the code to execute when invoking the interpreter. For example, on Windows:

py -c "print('Hello, world!')"

On Linux/macOS:

python -c "print('Hello, world!')"


terminal py


🐍 You might also find interesting: