Hello World in Minitab

Our first program will print the classic “hello world” message. Here’s the full source code.

def main():
    print("hello world")

if __name__ == "__main__":
    main()

To run the program, put the code in a file named hello_world.py and use python to execute it.

$ python hello_world.py
hello world

In Python, you typically do not need to build your programs into binaries as you would with lower-level languages. You run the script directly using the Python interpreter.

Python also supports packaging scripts into standalone executable files, though this is less common for simple scripts. Tools like pyinstaller can be used to achieve this:

First, install pyinstaller if you haven’t already:

$ pip install pyinstaller

Then, create an executable:

$ pyinstaller --onefile hello_world.py
$ ls dist
hello_world

We can then execute the built binary directly.

$ ./dist/hello_world
hello world

Now that we can run and build basic Python programs, let’s learn more about the language.