Back to blog
← View series: python tutorials

~/blog

Introduction to Python

Apr 1, 20264 min readBy Mohammed Vasim
PythonProgrammingTutorialBeginner

Introduction

Welcome to your first Python tutorial! In this lesson, you'll learn what Python is, why it's so popular, how to set up your development environment, and write your very first Python program.

Python is one of the most popular programming languages in the world. It's used for web development, data science, artificial intelligence, automation, and much more.

What You'll Learn

  • What Python is and why you should learn it
  • How to install Python on your computer
  • Setting up a code editor (VS Code)
  • Writing and running your first Python program
  • Understanding Python's philosophy

What is Python?

Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. It's known for its clean syntax and readability, making it perfect for beginners.

Why Learn Python?

FeatureBenefit
Easy to LearnSimple syntax similar to English
VersatileWeb, AI, Data Science, Automation, and more
High DemandOne of the most sought-after skills
Large CommunityTons of resources and libraries
Cross-PlatformWorks on Windows, Mac, Linux

Installing Python

Windows

  1. Visit python.org
  2. Download the latest version (Python 3.x)
  3. Run the installer
  4. Important: Check "Add Python to PATH"
  5. Click "Install Now"

macOS

Python usually comes pre-installed, but we recommend installing the latest version:

bash
# Using Homebrew (recommended)
brew install python

Linux

Most Linux distributions come with Python pre-installed. If not:

bash
# Ubuntu/Debian
sudo apt update
sudo apt install python3

# Fedora
sudo dnf install python3

Verifying Python Installation

Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and type:

python
python --version
# Output: Python 3.x.x

Or on some systems:

python
python3 --version
# Output: Python 3.x.x

Setting Up VS Code

Visual Studio Code (VS Code) is a free, powerful code editor recommended for Python development.

Installing VS Code

  1. Visit code.visualstudio.com
  2. Download for your operating system
  3. Install with default settings

Installing Python Extension

  1. Open VS Code
  2. Click the Extensions icon (or press Ctrl+Shift+X)
  3. Search for "Python"
  4. Install the one by Microsoft

Your First Python Program

Now let's write your first Python program - the classic "Hello, World!" program.

Using Interactive Mode

Open your terminal and type:

python
python
# You'll see >>> prompt

print("Hello, World!")
# Output: Hello, World!

Using a Python File

  1. Create a new folder for your Python projects
  2. Open VS Code and open that folder
  3. Create a new file named hello.py
  4. Add the following code:
python
# My first Python program
print("Hello, World!")

# You can print multiple things
print("Welcome to Python!")
print("This is your first program.")
  1. Run the program:
    • Press F5 or
    • Right-click and select "Run Python File"
    • Or in terminal: python hello.py

Expected Output:

Hello, World! Welcome to Python! This is your first program.

Understanding the print() Function

The print() function outputs text to the screen. It's one of the most used functions in Python.

python
# Basic usage
print("Hello")

# Multiple strings (automatically adds spaces)
print("Hello", "World")

# Using escape characters
print("Hello\nWorld")  # \n creates a new line
print("Tab\tSpace")    # \t creates a tab

# f-strings (formatted strings)
name = "Python"
print(f"Hello, {name}!")

Python's Philosophy

Python has a famous philosophy called "The Zen of Python". View it by running:

python
import this

You'll see principles like:

  • Beautiful is better than ugly
  • Explicit is better than implicit
  • Simple is better than complex
  • Readability counts

Summary

In this tutorial, you learned:

  • ✅ What Python is and why it's popular
  • ✅ How to install Python on Windows, Mac, and Linux
  • ✅ How to set up VS Code for Python development
  • ✅ How to write and run your first Python program
  • ✅ How the print() function works

🧑‍💻 Practice Exercise

Create a program that prints a greeting with your name. It should output something like:

Hello, my name is [Your Name]! I am learning Python.
Click to see solution
python
# My greeting program
name = "Your Name"
print(f"Hello, my name is {name}!")
print("I am learning Python.")

What's Next

In the next tutorial, we'll learn about Variables and Data Types - how Python stores and manipulates different kinds of data.

Variables & Basic Data Types →

Comments (0)

No comments yet. Be the first to comment!

Leave a comment