Welcome to the Day 1 of the 30days of Python in today lesson. We’ll cover the installation of Python on different platforms, introduce essential tools like Visual Studio Code (VS Code) for desktop coding, and Google Colab for coding on mobile devices.
1. Installing Python
Python is an easy-to-install, versatile programming language. Before we get into coding, let’s install Python.
Step 1: Downloading Python
Go to the official Python website.
You’ll see a button that says "Download Python 3.12" This button automatically selects the latest stable version for your system (Windows, macOS, or Linux).
Click the button to download the installer.
Step 2: Installing Python (Windows)
Once downloaded, open the Python installer.
IMPORTANT: Check the box that says "Add Python to PATH" (this allows you to run Python from the command line).
Choose Install Now for a simple installation.
After installation, open the Command Prompt and type
python --version
to confirm Python is installed.
Installing Python on macOS:
Download Python: Head over to python.org and download the macOS version of Python.
Run the Installer: Open the
.pkg
file that was downloaded and follow the instructions to install Python.Verify Installation: Open your terminal and type
python3 --version
. If installed successfully, you will see the Python version number.
Step 2: Installing Python (Linux)
On Linux, Python is usually pre-installed, but to install the latest version, open the terminal and use the following commands:
sudo apt update sudo apt install python3
Confirm installation by typing
python3 --version
.
2. Setting Up a Code Editor
A code editor is where you will write and test your Python code. Let’s set up a popular and powerful code editor: Visual Studio Code (VS Code).
Step 1: Download Visual Studio Code (VS Code)
Go to the Visual Studio Code website.
Download and install the version suitable for your operating system (Windows, macOS, or Linux).
Step 2: Installing Python Extension for VS Code
Open VS Code.
Go to the Extensions panel on the left (it looks like four squares).
Search for Python and install the extension by Microsoft. This extension provides features like syntax highlighting, code auto-completion, and integrated debugging.
Step 3: Setting Up Python in VS Code
Once the Python extension is installed, open any folder or create a new file with a
.py
extension.You should see a prompt to select a Python interpreter. Select the Python version you installed.
You can now write Python code and run it by pressing
Ctrl + Shift + P
and typingRun Python File
.
Example of a Simple Python Program in VS Code:
print("Hello, World!")
To run it, simply click the green "Run" button in the top-right corner of VS Code or use the terminal within VS Code.
3. Using Python on Mobile (with Google Colab)
If you don’t have access to a computer or prefer coding on your phone, you can use Google Colab—a cloud-based platform where you can write and execute Python code directly in your browser.
What is Google Colab?
Google Colab is an online platform that lets you write and run Python code for free.
It is perfect for coding on any device, including phones and tablets.
It provides access to powerful GPUs for more advanced computing.
Step 1: Accessing Google Colab
Open your browser (e.g., Chrome) and go to Google Colab.
If you’re not already logged in, sign in with your Google account.
Step 2: Starting a New Notebook
Click on New Notebook to start a new Python project.
A notebook interface will open where you can write Python code in "cells."
Step 3: Writing Python Code in Colab
In the code cells, you can type Python code. For example:
print("Hello from Google Colab!")
To run the code, press the Play button next to the cell, or press Shift + Enter
.
Step 4: Accessing Colab on a Phone or Tablet
Google Colab works seamlessly on mobile devices. Just open the Colab website in your mobile browser, and you’ll have access to all the same features as on a desktop.
Colab also supports Jupyter notebooks, which means you can import/export .ipynb
files, making it ideal for assignments, projects, and sharing code.
4. Additional Tools
Jupyter Notebook (for Local Use)
Jupyter Notebook is an interactive coding environment that allows you to write and run code in cells, similar to Google Colab.
It is particularly useful for students, as it lets you mix code, text (written in Markdown), and visualizations all in one document.
Installing Jupyter Notebook:
Open your terminal or command prompt and type:
pip install notebook
Once installed, run the following command to launch Jupyter:
jupyter notebook
A web browser will open with the Jupyter interface where you can create and run
.ipynb
notebooks.
Example of Using Jupyter:
In the Jupyter interface, you can create a new Python notebook and start by writing code in a cell like:
a = 5
b = 3
print(a + b)
To run the cell, press Shift + Enter
.
Thonny (For Beginners)
Thonny is a simple Python IDE designed for beginners. It provides a friendly interface and has built-in support for debugging.
If you’re new to programming and want a beginner-friendly IDE, Thonny is a good choice.
Installing Thonny:
Go to Thonny’s website.
Download and install the version suitable for your system.
Open Thonny and start writing Python code. It’s straightforward and doesn’t require additional configuration.
5. Using GitHub to Store and Share Code
As you advance in Python, it’s important to learn how to store and share your code using GitHub, a cloud-based platform for version control.
Step 1: Sign Up for GitHub
Go to GitHub and create a free account.
Once you have an account, you can create repositories (projects) to store your code.
Step 2: Installing Git (optional)
If you want to work with Git locally on your computer, install Git from the Git website. Once installed, you can manage your repositories directly from the command line.
6. Running Python in the Command Line (CLI)
For more advanced users or when you want to run simple scripts, you can execute Python programs directly from the command line.
Running Python on Windows:
Open Command Prompt.
Type
python
to enter the Python interactive shell, where you can type and execute Python code line-by-line.
Running Python on macOS/Linux:
Open Terminal.
Type
python3
to start the Python interpreter.
To run a Python file:
Navigate to the directory where your
.py
file is located using thecd
command.Type
python
filename.py
(orpython3
filename.py
on macOS/Linux) to execute your file.
7. Useful Resources for Learning Python
Official Python Documentation: The official Python documentation is the best place to find in-depth explanations and tutorials.
W3Schools: For quick references and examples, W3Schools Python Tutorial is beginner-friendly and easy to navigate.
Stack Overflow: If you run into errors or need help with a coding challenge, you can ask questions on Stack Overflow.
Conclusion
Now that your environment is ready, we’ll start exploring Python's fundamental concepts in the upcoming days. Stay tuned for Day 2, where we’ll dive into Python Basics, covering variables, data types, and comments.
Want to learn python in a more interactive manner
Join our 30days of Python development bootcamp where you would learn python in a very interactive and supportive environment
To get started, simply fill out the form below and secure your spot today!
30 Days of Python is brought to you by The AI Academy. To discover more topics and stay updated, visit our our website or follow us on facebook