No history yet

Introduction to Python

What Is Python?

Python is a programming language known for its clear, readable syntax. It was created in the late 1980s by Guido van Rossum, who wanted a language that was easy to write and understand, almost like plain English. This focus on simplicity is one of its biggest strengths.

Because it's so versatile, you'll find Python everywhere. It powers parts of Instagram, runs video games, analyzes scientific data, and automates tasks on your computer. If you can think of something you want a computer to do, there's a good chance Python can help.

Getting Set Up

To start writing Python, you need two things: the Python interpreter and a code editor.

The interpreter is the program that reads your Python code and carries out its instructions. You can download it for free from the official website, python.org. Just find the latest version for your operating system (Windows, macOS, or Linux) and follow the installation instructions.

A code editor is a text editor designed for writing code. It helps with formatting and highlights different parts of your code to make it easier to read. Some popular choices are Visual Studio Code, Sublime Text, and Atom. Any of them will work well for a beginner.

Your First Program

It's a tradition in programming to make your first program display the message "Hello, World!". Let's do that in Python. Open your code editor, create a new file, and save it as hello.py. The .py extension tells your computer it's a Python file.

Inside that file, type this single line:

print("Hello, World!")

This line uses Python's built-in print() function to display text on the screen. The text you want to display goes inside the parentheses, wrapped in quotation marks.

To run your program, open your computer's terminal or command prompt, navigate to the folder where you saved hello.py, and type the command python hello.py. You should see Hello, World! printed back at you.

Lesson image

The Rules of the Road

Every language has rules, and Python is no different. Its rules, called syntax, are simpler than most. But one rule is especially important: indentation.

Indentation refers to the spaces at the beginning of a line of code. In many languages, indentation is just for looks. In Python, it's a critical part of the syntax that organizes your code into blocks.

Think of it like an outline. Main points are on the left, and sub-points are indented underneath them. Python uses this same structure to understand which lines of code belong together. You'll see this more when you learn about concepts like loops and conditions. For now, just remember that the spacing matters. A misplaced space can cause an error.

Let's check your understanding of these foundational concepts.

Quiz Questions 1/5

Who is the creator of the Python programming language?

Quiz Questions 2/5

What is the primary role of the Python interpreter?

You've installed the tools, written your first lines of code, and learned the most important rule of Python syntax. You're ready to start building.