Introduction to Python

Discover why Python is the perfect first programming language and what you will learn in this course.

20 min read
Beginner

A new beginning

Welcome to this course on Python programming fundamentals!

Python is one of the world's most preferred programming language and it is known for its simplicity and versatility. It is often recommended as a first language for beginners because its syntax is simple and looks very close to plain English. This allows you to focus on learning programming concepts instead of worrying about complex rules.

Guido van Rossum is known as the original author of Python and it was released in 1991. Since then, it has grown into one of the most popular programming languages in the world.
Python: 27.89%
Python
1
C/C++: 16.17%
C/C++
2
Java: 11.74%
Java
3
R: 7%
R
4
Javascript: 5.24%
Javascript
5
Swift: 4.19%
Swift
6
PHP: 3.35%
PHP
7
Ranking based on PYPL PopularitY of Programming Language Index - Jan 2026

Advantages of Python

One of the best things about Python is how many different things you can do with it.

You can start small by writing simple programs and scripts while you’re learning. As you get more comfortable, you can move on to bigger projects like building websites, creating web applications, or even making games and desktop apps.

Python is also very popular for working with data. People use it to analyze numbers, process information, and automate boring or repetitive tasks, so instead of doing the same work again and again, you can let Python do it for you.

So once you learn Python, you can use it on almost any use case without having to relearn it.

Installing Python

Let's quickly install Python in your system so that we can get on with the course!

On Windows, Python is not installed by default, so you must download and install it manually.

Follow these steps to install Python on Windows:

  1. Visit the official Python website at python.org and download the latest stable version for Windows.
  2. Run the downloaded installer.
  3. Important: Check the option “Add Python to PATH” before clicking Install.
  4. Choose “Install Now” and wait for the installation to complete.

After installation, verify Python by opening Command Prompt and running:

bash
python --version

If Python is installed correctly, the version number will be displayed.

Great! Now that you have Python installed, you're ready to start writing and running Python code. In the next sections, we'll explore how to run Python code using different methods and tools.

Running Your First Line of Python Code

Once Python is installed, you're ready to write and run your first Python program. There are several ways to run Python code, and you can choose the one that feels most comfortable for you.

Interactive mode lets you type Python commands directly into the terminal/command prompt and see the results immediately. This is useful for quick tests and simple experiments.

To start interactive mode, type python or python3 in your terminal/command prompt and once >>> appears, you can start typing Python code:

bash
print("Hello, World!")

In script mode, you write Python code in a file with a .py extension and run it from the terminal. This is the standard way to build full Python programs.

Let's first create a hello.py file using any text editor (like Notepad, VS Code, etc.) and write the following code in it:

python
# hello.py
print("Hello, World!")

Now, open your terminal/command prompt, navigate to the directory where you saved the hello.py file, and run the script using the following command:

bash
python3 hello.py

As you might have noticed, both methods produced the same output. You can choose either method based on your needs. Interactive mode is great for quick tests and learning, while script mode is better for writing complete programs.

Running Python Code in an IDE

As you progress in this course, you'll find that using an Integrated Development Environment (IDE) or code editor can significantly enhance your coding experience.

IDEs provide features like syntax highlighting, code completion, and debugging tools that make writing and managing code easier. They also help you manage your Python scripts in a better way compared to using a simple text editor.

Jupyter Lab is an interactive, browser-based environment where you can write Python code, run it immediately, and see the output right away. It also lets you combine code with notes, explanations, and visualizations, making it ideal for learning and experimentation.

To use Jupyter Lab:

  1. Install it using pip or pip3 (if it's not already installed):
bash
pip3 install jupyterlab
  1. Start Jupyter Lab by running:
bash
jupyter lab

This command will open Jupyter Lab in your web browser.

  1. Create a new Python notebook (a file with the .ipynb extension).

Enter the following code in a cell and press Shift + Enter to run it:

python
print("Hello, World!")

Jupyter Lab is especially useful for trying out small pieces of code, learning step by step, and working with data and visualizations.

Visual Studio Code also supports Jupyter notebooks through the Jupyter extension. This option is great if you want the interactivity of notebooks along with the features of a full code editor.

Steps to use Jupyter in VS Code:

  1. Install the Jupyter extension (and optionally the Python extension) from the Extensions view.
  2. Open an existing .ipynb file or create a new one using File → New File… and selecting Jupyter Notebook, or by creating a file with the .ipynb extension.
  3. Choose a Python kernel from the kernel picker in the top-right corner. If needed, install a kernel by running:
bash
pip install ipykernel
  1. Run notebook cells using the ▶ play button or by pressing Shift + Enter.

Tips:

  • Use the Command Palette (Ctrl/Cmd + Shift + P) and search for Jupyter: Create New Blank Notebook to get started quickly.
  • If you use multiple Python environments, make sure the selected kernel matches the environment where your packages are installed.
python
print("Hello, World!")

As you continue through the lessons, you'll learn about variables, control flow, functions, data structures, and more. Try running each example in the environment you’re most comfortable with: practice is the best way to learn Python.

Comments in Python

Before we end this introduction lesson, you should get familiar with your first concept in Python: comments.

Comments are programmer-readable notes or annotations in the source code of a Python program and they are ignored by the Python interpreter when the code is executed.

There are two ways you can write comments in Python:

  1. Single Line Comment – Single line comments in Python begin with a hash symbol (#).
python
# The line below prints “Hello, World!” to the console
print("Hello, World!")

2. Multiline comment/Block Comments - A multiline comment is wrapped with a set of triple quotes (""").

python
"""
The line below prints “Hello, World!”
to the console
"""
print("Hello, World!")

You will see a lot of comments through the course to clarify certain portions of the code. Make sure to go through them!

Test your knowledge

🧠 Knowledge Check
1 / 11

What is one of Python's main advantages over other programming languages?