🐍 Install Python, VS Code and Formatter

Level 0 → Infinity Setup Lesson

Programmers Picnic AI-ML Classes by Champak Roy

🎯 Lesson Goal

In this lesson, students will learn how to install Python, install VS Code, set up Python extensions, configure a formatter, run their first Python program, and prepare a professional coding environment.

Final Result: By the end of this lesson, the student can create, run, format, and debug Python programs in VS Code.

🔰 Level 0: What Are We Installing?

Tool Purpose
Python The programming language we will use.
VS Code The editor where we write code.
Python Extension Adds Python support inside VS Code.
Pylance Helps with autocomplete and code intelligence.
Black Formatter Automatically cleans Python code formatting.

⚙️ Level 1: Install Python

Step 1: Open Python Website

Go to:

Open Python Download Page

Step 2: Download Python

Click the yellow download button for the latest Python version.

Very Important: While installing Python, tick the checkbox:
Add Python to PATH

Step 3: Install Python

Click:

Install Now

Step 4: Check Installation

Open Command Prompt or Terminal and type:

python --version

Expected output:

Python 3.x.x

🧩 Level 2: Install VS Code

Step 1: Open VS Code Website

Open VS Code Download Page

Step 2: Install VS Code

During installation, select these options:

Step 3: Open VS Code

After installation, open VS Code from the Start Menu or desktop shortcut.

🧠 Level 3: Install Required Extensions

In VS Code, press:

Ctrl + Shift + X

Search and install these extensions:

  1. Python by Microsoft
  2. Pylance
  3. Black Formatter
The Python extension helps VS Code understand Python files. Pylance gives autocomplete and error checking. Black Formatter makes code neat automatically.

📝 Level 4: Create Your First Python File

Step 1: Create a Folder

Create a folder named:

python-practice

Step 2: Open Folder in VS Code

In VS Code:

File → Open Folder → python-practice

Step 3: Create File

Create a file named:

first.py

Step 4: Write Code

a = 10
b = 5
c = a + b

print("a =", a)
print("b =", b)
print("c =", c)

▶️ Level 5: Run Python Code

There are three common ways to run Python code in VS Code.

Method 1: Right Click

Right click → Run Python File in Terminal

Method 2: Terminal Command

python first.py

Method 3: Run Button

Click the play/run button in the top-right corner of VS Code.

Expected output:

a = 10
b = 5
c = 15

🎨 Level 6: Install Formatter

A formatter automatically improves the spacing and structure of your code.

Install Black Formatter using pip

pip install black

Check Black Installation

black --version
Formatter does not change the meaning of your code. It only makes your code look clean and professional.

⚙️ Level 7: Enable Format on Save

In VS Code, press:

Ctrl + Shift + P

Search:

Preferences: Open User Settings JSON

Add this setting:

{
  "[python]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "ms-python.black-formatter"
  }
}
Be careful with commas in JSON. If there are existing settings, you may need to add a comma before inserting new settings.

🧪 Level 8: Formatter Test

Write ugly code like this:

a=10
b=5
print( a+b )

Save the file using:

Ctrl + S

After saving, it should become:

a = 10
b = 5
print(a + b)

📦 Level 9: Virtual Environment

A virtual environment keeps each project separate. This is very important for serious Python, AI, ML, and web development.

Create Virtual Environment

python -m venv venv

Activate on Windows

venv\Scripts\activate

Activate on Mac/Linux

source venv/bin/activate

Install Package Inside Environment

pip install numpy

Save Installed Packages

pip freeze > requirements.txt

Install from requirements.txt

pip install -r requirements.txt

🧹 Level 10: Linting and Code Quality

A formatter fixes style. A linter warns about possible mistakes.

Install Ruff

pip install ruff

Run Ruff

ruff check .

Auto Fix Some Issues

ruff check . --fix
Black is for formatting. Ruff is for checking code quality. Together, they create a professional workflow.

🐞 Level 11: Debugging in VS Code

Debugging means running code step by step and watching variables.

Steps

  1. Open your Python file.
  2. Click on the left side of a line number to add a breakpoint.
  3. Press F5.
  4. Select Python Debugger if asked.
  5. Watch variables while the program runs.

Example debug code:

a = 20
b = 10

addition = a + b
subtraction = a - b
multiplication = a * b
division = a / b

print(addition)
print(subtraction)
print(multiplication)
print(division)

📁 Level 12: Professional Project Structure

A clean Python project can look like this:

my-python-project/
│
├── venv/
├── src/
│   └── main.py
├── tests/
│   └── test_main.py
├── requirements.txt
├── README.md
└── .gitignore

What Each Part Means

Item Meaning
venv Virtual environment folder
src Main source code
tests Test files
requirements.txt List of packages
README.md Project explanation
.gitignore Files Git should ignore

⌨️ Useful Keyboard Shortcuts

Action Shortcut
Open Command Palette Ctrl + Shift + P
Open Terminal Ctrl + `
Save File Ctrl + S
Run Without Debugging Ctrl + F5
Start Debugging F5
Format Document Shift + Alt + F

📸 Screenshot Guide for Students

Students should take these screenshots and submit them as proof of setup. Replace each placeholder with your own uploaded image URL if using this on Blogspot.

Screenshot 1: Python Download Page

Show the Python download button.

Paste Python Download Screenshot Here

Screenshot 2: Add Python to PATH

Show the checkbox “Add Python to PATH”.

Paste Add Python to PATH Screenshot Here

Screenshot 3: Python Version Check

Show terminal output of:

python --version
Paste Python Version Screenshot Here

Screenshot 4: VS Code Installed

Show VS Code open on your computer.

Paste VS Code Screenshot Here

Screenshot 5: Extensions Installed

Show Python, Pylance, and Black Formatter extensions.

Paste Extensions Screenshot Here

Screenshot 6: First Program Output

Show first.py and terminal output.

Paste First Program Screenshot Here

Screenshot 7: Formatter Working

Show code before and after formatting.

Paste Formatter Screenshot Here

✅ Final Student Checklist

🧮 Final Assignment: Calculator Program

Create a file named:

calculator.py

Write this code:

a = 20
b = 10

print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Floor Division:", a // b)
print("Modulus:", a % b)
print("Power:", a**b)

Student Tasks

  1. Run the program.
  2. Take screenshot of output.
  3. Change values of a and b.
  4. Run again.
  5. Explain each operator in your own words.

🧠 Mini Quiz

  1. What is Python?
  2. What is VS Code?
  3. Why do we tick Add Python to PATH?
  4. What is a formatter?
  5. What does Black Formatter do?
  6. What is a virtual environment?
  7. What is the use of pip?
  8. Which shortcut opens the terminal in VS Code?
  9. What is debugging?
  10. Why should we use clean project structure?

🚀 Level Infinity: Professional Workflow

A professional Python developer follows this workflow:

  1. Create project folder.
  2. Open folder in VS Code.
  3. Create virtual environment.
  4. Activate virtual environment.
  5. Install required packages.
  6. Write code inside proper files.
  7. Use formatter on save.
  8. Use linter to detect mistakes.
  9. Debug when code does not work.
  10. Save dependencies in requirements.txt.
This is the foundation for Python, Data Science, AI, Machine Learning, Automation, Web Development, and Software Engineering.

🔖 Blogspot Search Description

Learn how to install Python, VS Code, Python extensions, Black Formatter, virtual environment, pip, debugging, and professional Python setup from level 0.

🏷️ Blogspot Labels

Python VS Code Formatter Black Setup Coding Programming Python Install Editor Beginner AI ML Tools PATH Pip Extensions Debugging Code Run Lesson Champak