Lesson Objectives
By the end of this lesson, you will be able to:
- Install Python correctly on your system
- Configure Visual Studio Code as a professional Python IDE
- Run Python scripts from the terminal
- Understand how this setup scales to data analysis and machine learning
This lesson is foundational.
A poor environment setup will compromise everything that follows.
1️⃣ What Is Python (and Why We Use It)
Python is a high-level, general-purpose programming language designed to prioritize:
- readability
- expressiveness
- rapid development
Python is widely adopted in:
- scientific computing
- statistical analysis
- machine learning
- artificial intelligence
- automation and scripting
In this course, Python is not an end in itself.
It is the computational backbone for advanced analytical workflows.
2️⃣ Installing Python (The Correct Way)
Step 1 — Download Python
Always download Python from the official source:
https://www.python.org
Install Python 3.10 or newer.
Avoid unofficial installers or OS-level package managers unless you know exactly what you are doing.
Step 2 — Installation Options (Critical)
During installation:
✅ Check the option
Add Python to PATH
Do not skip this step
Why this matters:
- The PATH variable allows your system to locate Python
- Without it, Python commands will fail silently or unpredictably
Step 3 — Verify Installation
Open a terminal (Command Prompt / PowerShell / Terminal):
python --version
Expected output:
Python 3.12.x
If this command fails, Python is not properly installed.
3️⃣ Installing Visual Studio Code
Why Visual Studio Code?
Visual Studio Code (VS Code) is a lightweight but professional-grade code editor.
We use VS Code because it:
- scales from beginner to expert
- integrates seamlessly with Python
- supports debugging, linting, and testing
- is widely used in scientific and industrial contexts
Step 1 — Download VS Code
Official website:
Install using default settings.
Step 2 — Install Python Extensions
In VS Code → Extensions panel, install:
- Python (Microsoft)
- Pylance
These extensions provide:
- syntax highlighting
- intelligent autocomplete
- inline error detection
- type inference
This is essential when working with complex analytical code later.
4️⃣ Creating Your First Python Project
Step 1 — Create a Project Folder
Create a folder, for example:
python_course
Open it in VS Code:
File → Open Folder
Step 2 — Create a Python File
Inside the folder, create:
lesson01.py
5️⃣Writing Your First Python Code
Insert the following code:
print("Hello, Python!")
Code Explanation (Line by Line)
print()is a built-in Python function"Hello, Python!"is a string literal- The function outputs the string to the console
Python is an interpreted language:
the code is executed line by line, without compilation.
6️⃣ Running the Script
Option 1 — Terminal Execution (Recommended)
In the VS Code terminal:
python lesson01.pyExpected output:
Hello, Python!Option 2 — VS Code Run Button
You may also use the ▶ Run button.
Both approaches are valid, but terminal execution builds better mental models for later work.
7️⃣ Common Beginner Errors (and Why They Matter)
Missing quotation marks
print(Hello)
Error:
NameError: name 'Hello' is not defined
Explanation:
- Python interprets unquoted text as variable names
Using typographic quotes
print(“Hello”)
Explanation:
- Python only accepts straight quotes (
"or')
Forgetting to save the file
Always save before running.
8️⃣ How This Setup Scales to Advanced Python
This exact environment will later support:
- numerical libraries (
numpy,scipy) - data analysis (
pandas) - visualization (
matplotlib,seaborn) - machine learning (
scikit-learn) - reproducible research pipelines
You will not need to change tools, only add complexity.
FAQ — Frequently Asked Questions
Q: Why not start with Jupyter notebooks?
A: Scripts teach execution flow and structure. Notebooks come later.
Q: Should I install Anaconda?
A: Not yet. Understanding the standard Python ecosystem first is critical.
Q: Is Python suitable for serious scientific work?
A: Yes. Most modern scientific pipelines rely on Python.
Q: Will this work on Windows, macOS, and Linux?
A: Yes. Python is cross-platform.
Exercises
Exercise 1
Print your name.
Exercise 2
Print your age.
Exercise 3
Print two lines of text.
Exercise 4
Print a sentence containing quotes.
Exercise 5
Print a number.
Exercise 6
Print the result of 10 + 5.
Exercise 7
Print a string and a number on the same line.
Exercise 8
Use \\n to print text on two lines.
Exercise 9
Modify the file and run it again.
Exercise 10
Create a new file test.py and run it.
Solutions
Exercise 1
print("Michele")
Exercise 2
print(42)
Exercise 3
print("Line one")
print("Line two")
Exercise 4
print('He said "Python is powerful"')
Exercise 5
print(100)
Exercise 6
print(10 + 5)
Exercise 7
print("Age:", 42)
Exercise 8
print("First line\\nSecond line")
Exercise 9
# Save and re-run the file
Exercise 10
# test.py
print("This is a new file")
Next Lesson Preview
In Lesson 03, we will cover:
- variables
- naming conventions
- Python syntax fundamentals
- how Python stores and manipulates data
