Lab Activity: Intro to Python
Step 1: Install Python
Objective:
Install the latest version of Python on your system.
step-by-step Instructions:
-
Visit the official website: https://www.python.org
-
Download the appropriate installer for your operating system.
-
Run the installer and check the box for “Add Python to PATH”.
-
Verify the installation:
python --version
Step 2: Install and Set Up VS Code
Objective:
Set up a code editor for Python development.
Instructions:
-
Download and install Visual Studio Code.
-
Open VS Code and install the Python extension from Microsoft.
-
Create a folder named
MyFirstPythonProjectand open it in VS Code. -
Inside the folder, create a file named
hello.py.
Step 3: Run Your First Python Program
Objective:
Write and execute your first Python script.
Instructions:
-
Open the
hello.pyfile in VS Code. -
Write the following code:
print("Hello, World!") -
Run the file using:
-
The “Run” button in VS Code OR
-
Terminal command:
python hello.py
-
Step 4: Install Python Packages Using pip
Objective:
Use pip to install packages.
Instructions:
-
Open Command Prompt or Terminal.
-
Install the
requestspackage:python -m pip install requests -
Verify it is installed:
pip show requests -
Write a short script to import and print the version of
requests:import requests print(requests.__version__)
