Title here
Summary here
Our first program will print the classic “hello world” message. Here’s the full source code.
# hello_world.py
def main():
print("hello world")
if __name__ == "__main__":
main()
To run the program, save the code in hello_world.py
and use the python
command.
$ python hello_world.py
hello world
Sometimes we’ll want to build our programs into standalone executables. While Python is typically interpreted rather than compiled, you can use tools like PyInstaller
to create executables.
First, install PyInstaller:
$ pip install pyinstaller
Then, create the 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.