Curriculum
Before you can start writing some Python code, you would need to install some software on your computer.
In this section, we will cover the following subjects:
By the end of this section, you should have Python fully installed and ready to use.
While you navigate the course content, feel free to also refer to additional material on the free content link at GeeksForGeeks. This provides you with an alternative perspective to the content in this course.
You can check whether Python has already been installed on the system that you intend to use for the course.
In certain instances, the interpreter could already exist based on the platform, such as with macOS systems.
To confirm if the interpreter exists, use the appropriate instruction from below based on your operating system:
python --version
or
python3 --version
python3 --version
If Python is installed, you will see an output like:
Python 3.10.5
python-3.x.x.exe) and double-click it to start the installation.After installation, open the Command Prompt (cmd) and type in the following:
python --version
You should see something similar to the printout below:
Python 3.10.5
Most macOS versions come with Python pre-installed. Confirm this by running the following line:
python3 --version
If it prints out a version lower than Python 3.7, you would need to install the latest version.
Homebrew is a package manager for macOS that makes installation easier.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. Install Python using Homebrew:
brew install python
3. Verify the installation:
python3 --version
You should then see the following output:
Python 3.10.5
Most Linux distributions come with Python pre-installed. To check:
python3 --version
If Python is not installed or needs an update, use apt:
sudo apt update
sudo apt install python3
Use dnf:
sudo dnf install python3
Verify installation by running:
python3 --version
pip allows you to install external Python libraries.
Python 3.x comes with pip pre-installed, but you can manually install or upgrade it:
pip --version
python -m pip install --upgrade pip
pip install --upgrade pip
Now you can install packages like NumPy, pandas, Flask, etc.
Example: Installing NumPy
pip install numpy
Once you have successfully installed the Python interpreter, you can run it directly in two ways:
Python provides an interactive shell (Read-Eval-Print Loop, REPL) where you can type commands and get instant results.
Open Command Prompt (Windows) or Terminal (macOS/Linux) and type:
python
or
python3
You will see the Python prompt (>>>), indicating that Python is ready to execute commands.
Example: Running Python Commands in REPL
Try the scripts below
>>> print("Hello, Python!")
Hello, Python!
>>> 2 + 3
5
>>> exit() # Type 'exit()' to leave the Python shell
This is how you use Python interactively. But we shall not use this approach.
Python scripts are files with the extension .py . This indicates that the file contains Python code.
Example: Creating and Running a Python Script
Open a text editor (Notepad, VS Code, or PyCharm – Next Section).
Type the following code and save the file as hello.py:
print("Welcome to Python Programming!")
Open Command Prompt/Terminal, navigate to the file’s location, and run:
python hello.py
Output:
Welcome to Python Programming!
Terrific! you have successfully written and executed your first Python script!
While Python can be run in the terminal, using an Integrated Development Environment (IDE) improves coding efficiency.
While we shall cover the installation of PyCharm in the next section, we will discuss below the available IDEs for writing Python code.
Popular Python IDEs and Code Editors:
| IDE/Editor | Features | Best For |
|---|---|---|
| PyCharm | Full-featured, debugging, autocomplete | Professionals |
| VS Code | Lightweight, extensions, debugging | Beginners & Professionals |
| Jupyter Notebook | Best for Data Science, inline graphs | Data Science, AI |
| IDLE | Comes with Python, simple interface | Absolute Beginners |
Here is a summary of what we have discussed in this section.
brew install python).sudo apt install python3).python --version.pip install --upgrade pip.python in the terminal..py file and execute it.Now that you have installed Python, let’s move to Chapter 1.4: Setting Up PyCharm as Your IDE, where we will configure PyCharm for a professional coding experience.
We noticed you're visiting from United Kingdom (UK). We've updated our prices to Pound sterling for your shopping convenience. Use United States (US) dollar instead. Dismiss
Not a member yet? Register now
Are you a member? Login now