#!/usr/bin/env python print("Hello World")
- Create a file called hello.py with the above content.
- Open your terminal (or Cmd window on MS Windows in the directory (folder) where you saved the file.
- Run it by typing python hello.py.
- In reality for this you only need the line with the word print in it. The first line staring with # is only needed on Linux and only if you want to have a file that can be executed without explicitly typing in python as well.
- On unix you can also make it executable: chmod u+x hello.py and then run like: ./hello.py
- The extension is .py - mostly for the editor (but also for modules).
- Parentheses after print() are only required in Python 3, but we better get used to them even if for some reason you have to write code for a Python 2 interpreter.