No history yet

Introduction to Python

What is Python?

Python is a programming language, which is a way for humans to give instructions to computers. Think of it like a recipe. You write the steps, and the computer follows them to bake a cake—or run an application, analyze data, or create a website.

Python is a versatile, high-level programming language known for its readability and simplicity.

It's called a “high-level” language because its syntax is closer to human language than to the ones and zeros a computer understands. This makes it easier to read and write. It's also an “interpreted” language, meaning you can run your code line by line, which makes finding mistakes much simpler.

Python was created in the late 1980s by Guido van Rossum. He wanted to make a language that was powerful but also fun to use. The name doesn't come from the snake, but from the British comedy troupe Monty Python.

Lesson image

Why Python Stands Out

The biggest reason for Python's popularity is its simplicity. Writing code in Python feels a lot like writing in English. This design philosophy emphasizes code readability, meaning that programs are easier to understand, share, and maintain.

Another key feature is its massive standard library, often described as “batteries included.” This means Python comes with a huge collection of pre-written code (modules) that you can use for tasks like working with dates, sending emails, or handling files, without having to write everything from scratch.

This simplicity and power make Python incredibly versatile. It’s not just for one specific job. Programmers use it for a huge range of applications.

Lesson image

Some common uses include:

  • Web Development: Building the server-side logic of websites and applications using frameworks like Django and Flask.
  • Data Analysis & Machine Learning: Scientists and analysts use libraries like Pandas, NumPy, and TensorFlow to process data, create visualizations, and build predictive models.
  • Automation: Writing scripts to automate repetitive tasks, like organizing files, scraping data from websites, or managing system administration tasks.

Getting Started

To start writing Python, you first need to install the Python interpreter on your computer. The interpreter is the program that reads your Python code and translates it into instructions the computer can execute.

You can download the official installer from python.org. The website automatically detects your operating system (like Windows or macOS) and suggests the correct version.

Lesson image

During installation, it’s a good idea to check the box that says “Add Python to PATH” on Windows. This makes it easier to run Python from your computer's command line.

Once installed, Python comes with a simple program called IDLE (Integrated Development and Learning Environment). It gives you a place to write and run your code right away.

Your First Program

It’s a tradition for new programmers to start by making the computer display the phrase “Hello, World!”. This simple task confirms that your setup is working correctly. In Python, this takes just one line of code.

We use the built-in print() function. A function is a named block of code that performs a specific task. The print() function's job is to display text on the screen. Whatever you put inside the parentheses and quotes will be printed.

# This one line of code will print the message to the screen.
print("Hello, World!")

To run this, you can open IDLE, type that line into the shell window, and press Enter. You should immediately see the output:

Hello, World!

Alternatively, you can save the code in a text file with a .py extension, like hello.py. Then, you can run the file from your computer's terminal or command prompt by typing python hello.py.

Lesson image

Congratulations, you've just written and run your first Python program! This is the first step on a long and rewarding journey.