Day 1 - 
Python Installation and Setup Guide

Day 1 - Python Installation and Setup Guide

·

6 min read

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

  1. Go to the official Python website.

  2. 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).

  3. Click the button to download the installer.

Step 2: Installing Python (Windows)

  1. Once downloaded, open the Python installer.

  2. IMPORTANT: Check the box that says "Add Python to PATH" (this allows you to run Python from the command line).

  3. Choose Install Now for a simple installation.

  4. After installation, open the Command Prompt and type python --version to confirm Python is installed.

Installing Python on macOS:

  1. Download Python: Head over to python.org and download the macOS version of Python.

  2. Run the Installer: Open the .pkg file that was downloaded and follow the instructions to install Python.

  3. Verify Installation: Open your terminal and type python3 --version. If installed successfully, you will see the Python version number.

Step 2: Installing Python (Linux)

  1. 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
    
  2. 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)

  1. Go to the Visual Studio Code website.

  2. Download and install the version suitable for your operating system (Windows, macOS, or Linux).

Step 2: Installing Python Extension for VS Code

  1. Open VS Code.

  2. Go to the Extensions panel on the left (it looks like four squares).

  3. 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

  1. Once the Python extension is installed, open any folder or create a new file with a .py extension.

  2. You should see a prompt to select a Python interpreter. Select the Python version you installed.

  3. You can now write Python code and run it by pressing Ctrl + Shift + P and typing Run 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

  1. Open your browser (e.g., Chrome) and go to Google Colab.

  2. If you’re not already logged in, sign in with your Google account.

Step 2: Starting a New Notebook

  1. Click on New Notebook to start a new Python project.

  2. 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:

  1. Open your terminal or command prompt and type:

     pip install notebook
    
  2. Once installed, run the following command to launch Jupyter:

     jupyter notebook
    
  3. 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:

  1. Go to Thonny’s website.

  2. Download and install the version suitable for your system.

  3. 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

  1. Go to GitHub and create a free account.

  2. 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:

  1. Open Command Prompt.

  2. Type python to enter the Python interactive shell, where you can type and execute Python code line-by-line.

Running Python on macOS/Linux:

  1. Open Terminal.

  2. Type python3 to start the Python interpreter.

To run a Python file:

  1. Navigate to the directory where your .py file is located using the cd command.

  2. Type python filename.py (or python3 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!

Visit here to get started

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