about
Bits Hello Python
09/04/2023
0
Bits Repo Code Bits Repo Docs

Bits: Hello Python

code, output, and build for Python on Windows, macOS, and Linux

These pages support comparison of fragments of code in several different languages, much as you might compare a sentence of English with one in Spanish to help you learn Spanish.

Synopsis:

This page demonstrates use of Visual Studio Code to build and execute a simple Python "Hello World" program, showing its build process and launch file. The purpose is to show how to get started quickly.
  • Companion pages for C++, Rust, C#, and JavaScript are accessible from the links in the fixed right panel.
  • Navigation through example levels for the same language is effected with the "Next" and "Prev" buttons in the menus or by using the "N" and "P" keys.
  • The links in the left panel point to major sections of this page and all of the Bits pages for Python.
Note:
Most page links in this site refer to specific points in a target page, usually the top. For all of the code bits here, links return to the last scroll position. This supports quickly moving between similar code for each of the languages covered. That maintains context for comparisons.

Source Code

Code below is a fragment taken from Bits Repository. You can download the repo containing code for all Bits by opening the "Code" dropdown in that page.
# HelloWorld::Py_Hello.py

print("\n  Hello Python World\n")

Output

This is output from the Python source code above, running in Visual Studio Code. The output is retrieved in an embedded terminal window. VS Code runs on Windows, Linux, and macOS.
C:\github\JimFawcett\Bits\Python\Py_Hello
> python Py_Hello.py

  Hello Python World

C:\github\JimFawcett\Bits\Python\Py_Hello
>
          

Build

No explicit build process for Python. On launch, source code is compiled to byte code that is interpreted in the Python Virtual Machine.

Create Project

The terminal session below shows how to create a project for Python. See tooling information here: Bits_Tooling.
C:\github\JimFawcett\test
> mkdir Python_Hello

    Directory: C:\github\JimFawcett\test

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2/24/2023   3:02 PM                Python_Hello

C:\github\JimFawcett\test
> cd Python_Hello
C:\github\JimFawcett\test\Python_Hello
> New-Item -path "." -type file -name "Py_Hello.py"

    Directory: C:\github\JimFawcett\test\Python_Hello

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         2/24/2023   3:03 PM              0 Py_Hello.py

C:\github\JimFawcett\test\Python_Hello
>

2.0 VS Code View

The code for this demo is available in github.com/JimFawcett/Bits. If you click on the Code dropdown you can clone the repository of all code for these demos to your local drive. Then, it is easy to bring up any example, in any of the languages, in VS Code. Here, we do that for Python\Python_Hello. Figure 1. VS Code IDE - Python Hello Figure 2. Launch.JSON - Python Hello Figure 3. Python Plugins

3.0 References

ReferenceDescription
Python Tutorial - docs.python.org E-book with sixteen chapters covering most of intermediate Python
Python Tutorial - pythontutorial.net Basic syntax and operations
Python Introduction - w3schools Interactive examples - good coverage
Bits Tooling Tool chains, VS Code