No history yet

Introduction to Python

Meet Python

Python is a popular, versatile programming language known for its clear and readable syntax. Created in the late 1980s by Guido van Rossum, its design philosophy emphasizes code readability, making it a great choice for beginners.

Despite its simplicity, Python is incredibly powerful. It's used everywhere: from building websites and apps (like Instagram and Spotify) to analyzing data, powering artificial intelligence, and automating repetitive tasks. Its extensive collection of libraries—pre-written code you can use—means you can accomplish a lot with relatively few lines of code.

Getting Set Up

To start writing Python, you first need to install the Python interpreter. This is the program that reads your Python code and carries out its instructions. The official source for the interpreter is python.org. The website provides easy-to-follow installers for Windows, macOS, and Linux.

Lesson image

When you install Python, you also get a simple built-in development environment called IDLE (Integrated Development and Learning Environment). IDLE includes a text editor for writing longer programs and an interactive shell for experimenting with code snippets. It's all you need to get started.

Your First Program

A long-standing tradition in programming is to make your first program display the text "Hello, World!". In Python, this is remarkably simple. It takes just one line of code.

print("Hello, World!")

Here, print() is a built-in function that tells the computer to display whatever is inside the parentheses. The text you want to display, like "Hello, World!", must be enclosed in quotes.

You can write this code in a text editor, save it with a .py extension (like hello.py), and then run it. Or, for quick tests, you can use the interactive shell.

Lesson image

The Interactive Shell

The Python interactive shell is a tool that lets you run Python code one line at a time. It's also known as a REPL, which stands for Read-Eval-Print Loop. It reads the code you type, evaluates it, prints the result, and waits for your next command. You'll know you're in the shell when you see the >>> prompt.

The interactive shell is perfect for testing small ideas, doing quick calculations, or exploring how a function works without having to create a new file.

For example, you can use it as a simple calculator.

>>> 2 + 2
4
>>> 100 / 5
20.0

You can also run the print() function directly.

>>> print("This is the interactive shell!")
This is the interactive shell!
Quiz Questions 1/5

What is the primary design philosophy of the Python programming language?

Quiz Questions 2/5

Which line of code will correctly display the text "Hello, World!"?

You've taken the first steps into the world of Python. You know what it is, how to set it up, and how to write and run a basic command.