bhylu.com

Advertisements

Python Get Started

Your first Python program should be easy to run and easy to recognise when it works. A single print call is enough to check the editor and interpreter.

Understand the idea

The browser playground loads a Python runtime when you choose Run. For a local Windows setup, install Python and check py --version in a terminal. Save code as hello.py and use py hello.py from its folder. A virtual environment comes later when you add project dependencies.

Where to try it

Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.

A worked example

Python

import sys
print("Workshop ready")
print(sys.version_info.major)

Read the result

The first line says Workshop ready and the second reports 3 for Python 3. The full minor version depends on the environment.

Try one change

Change the greeting and run the saved file twice. Check which interpreter your editor selected.