Skip to main content

Lab 00 — Install Python & Write Your First Program

Hands-on Lab 30 min Beginner

Objectives

By the end of this lab, you will be able to:

  1. Verify a working Python 3 installation
  2. Use the Python REPL interactively
  3. Create and run a .py script from the terminal
  4. Use VS Code to write, run, and debug Python code
  5. Apply input(), print(), and basic arithmetic

Prerequisites

  • Python 3.10+ installed (see lesson 00.2)
  • VS Code installed with the Python extension

Step 1 — Verify Your Installation

Open your terminal (PowerShell on Windows, Terminal on macOS/Linux):

python3 --version
pip3 --version

Verification ✅

Expected output:

Python 3.11.x
pip 23.x from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

If you see Python 2.x, use python3 explicitly. If Python is not found, re-install and check the "Add to PATH" option.


Step 2 — Explore the Python REPL

Open your terminal and type python3:

>>> # Try arithmetic
>>> 10 + 5
15
>>> 10 / 3
3.3333333333333335
>>> 10 // 3
3
>>> 10 % 3
1
>>> 2 ** 10
1024

>>> # Try strings
>>> "Hello" + " " + "World"
'Hello World'
>>> "Python" * 3
'PythonPythonPython'

>>> # Try built-in help
>>> help(print)
# Press Q to exit help

>>> exit()

Verification ✅

You should see each result printed immediately after your input. The REPL is Python's playground — use it any time you want to quickly test a snippet.


Step 3 — Create Your Project Folder

# Create a projects directory
mkdir ~/python-course
cd ~/python-course
mkdir lab-00
cd lab-00

Open this folder in VS Code:

code .

Step 4 — Write an Interactive Profile Script

Create a new file profile.py in VS Code:

#!/usr/bin/env python3
"""
Lab 00 — Personal Profile Script
Collects user information and displays a formatted summary.
"""

def get_user_profile():
"""Collect user information interactively."""
print("=" * 40)
print(" Welcome to the Python Profile Lab")
print("=" * 40)

name = input("\nEnter your name: ")
age = int(input("Enter your age: "))
city = input("Enter your city: ")
language = input("What is your favourite programming language? ")

return {
"name": name,
"age": age,
"city": city,
"language": language
}


def display_profile(profile):
"""Display a formatted user profile."""
print("\n" + "=" * 40)
print(" YOUR PROFILE SUMMARY")
print("=" * 40)
print(f" Name : {profile['name']}")
print(f" Age : {profile['age']} years old")
print(f" City : {profile['city']}")
print(f" Fav lang: {profile['language']}")
print("=" * 40)

# Fun facts
birth_year = 2026 - profile["age"]
print(f"\n You were born around {birth_year}.")
print(f" In 5 years, you will be {profile['age'] + 5}.")

if profile["language"].lower() == "python":
print(" Great choice — Python is #1! 🐍")
else:
print(f" {profile['language']} is good too, but Python is better 😄")

print()


if __name__ == "__main__":
user_profile = get_user_profile()
display_profile(user_profile)

Step 5 — Run the Script

In the VS Code terminal (Ctrl+``) or your system terminal:

python3 profile.py

Verification ✅

Expected interaction:

========================================
Welcome to the Python Profile Lab
========================================

Enter your name: Alice
Enter your age: 28
Enter your city: Montreal
What is your favourite programming language? Python

========================================
YOUR PROFILE SUMMARY
========================================
Name : Alice
Age : 28 years old
City : Montreal
Fav lang: Python
========================================

You were born around 1998.
In 5 years, you will be 33.
Great choice — Python is #1! 🐍

Step 6 — Debug with VS Code

  1. Click the gutter (left of line numbers) next to line display_profile(user_profile) to add a breakpoint (red dot)
  2. Press F5 and select "Python File"
  3. Fill in the prompts
  4. When execution pauses at the breakpoint, inspect user_profile in the Variables panel on the left

Verification ✅

You should see user_profile with all its keys (name, age, city, language) in the Variables panel. Press F5 to continue.


Bonus Challenge

Extend profile.py to:

  1. Ask for the user's skills as a comma-separated list (e.g., "Python, Docker, SQL")
  2. Split the string into a Python list using .split(", ")
  3. Display "You have X skills" where X is the length of the list
# Hint
skills_input = input("Enter your skills (comma-separated): ")
skills = skills_input.split(", ")
print(f"You have {len(skills)} skills: {skills}")

Cleanup

No cloud resources to clean up — this lab runs entirely on your local machine.


Summary

In this lab you:

  • Verified Python 3 is installed and accessible from the terminal
  • Used the Python REPL to test expressions interactively
  • Created a structured Python script with functions, input(), print(), and f-strings
  • Ran and debugged the script using VS Code