Hello World

Hello World: Interactive Mode

Interactive Mode

  • Python interpreter, invoked without arguments

  • Like Shell prompt, only with Python

  • Exit ⟶ type exit(), or End-of-file (EOF):

    • Unix (Linux, Mac): Ctrl + d

    • Windows: Ctrl + z

$ python
Python 3.9.9 (main, Nov 19 2021, 00:00:00)
[GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World")
Hello World

Hello World: Script Files

The first and simplest program …

print("Hello World")

Run it like so:

$ python hello-world.py
Hello World


This way of running Python programs works on both Unix and Windows, because the Python interpreter is invoked by hand.

See Running Python Programs for other, OS dependent, ways to run Python programs.