Skip to content
Novus Examples
py168 B

Python — Hello World

The classic hello-world in idiomatic Python 3, with a shebang, a module docstring, and the standard main guard — the minimal correct program for testing highlighters and interpreters.

Preview — first 11 linespy
#!/usr/bin/env python3
"""The classic first program, in idiomatic Python 3."""


def main() -> None:
    print("Hello, world!")


if __name__ == "__main__":
    main()

Specifications

Language
Python
Kind
hello-world
Lines
10
Encoding
UTF-8
Line Endings
LF

What is a .py file?

Python (.py) is a plain-text source file for the Python programming language — a dynamically typed, indentation-structured language widely used for scripting, data science, web back-ends, and automation. A .py file is compiled to bytecode and run by the Python interpreter.

How to use this file

Use an example .py file to test syntax highlighters, linters (like flake8 or ruff), formatters (black), tree-sitter grammars, and language-detection or code-editor tooling against known-correct source.

Generated by generation/code_samples.py. Free for any use, no attribution required — license.