No history yet

Introduction to Python

What is Python?

Python is a programming language known for its clear, readable syntax. Think of it less like a dense legal document and more like a straightforward set of instructions. It was created in the late 1980s by Guido van Rossum, who named it after the British comedy group Monty Python's Flying Circus.

Lesson image

Its design philosophy emphasizes code readability, which means you'll spend less time trying to figure out what code does and more time making it work. This simplicity makes it an excellent language for beginners.

But don't let its simplicity fool you. Python is incredibly versatile. It's used by companies like Google, Netflix, and NASA for everything from building websites and analyzing data to powering artificial intelligence and automating repetitive tasks.

Getting Python Ready

Before you can write Python code, you need to install it on your computer. It's a bit like needing a kitchen before you can start cooking. Many Mac and Linux computers come with Python already installed, but it might be an older version. It's always best to get the latest official release.

You can download the latest version of Python for Windows, macOS, or Linux directly from the official website: python.org.

The installation process is straightforward. Just run the installer you downloaded and follow the on-screen instructions. On Windows, be sure to check the box that says "Add Python to PATH" during installation. This small step will make it much easier to run your programs later.

Your First Program

It's a tradition in programming to start by making the computer say "Hello, World!". This simple task confirms that your setup is working correctly. In Python, this is incredibly easy. All you need is the print() function, which tells the computer to display whatever you put inside the parentheses.

print("Hello, World!")

To run this code:

  1. Open a plain text editor (like Notepad on Windows or TextEdit on Mac).
  2. Type the line of code above.
  3. Save the file as hello.py. The .py extension is important; it tells the computer this is a Python file.
  4. Open your computer's command prompt or terminal.
  5. Navigate to the directory where you saved your file.
  6. Type python hello.py (or python3 hello.py on some systems) and press Enter.

You should see the text Hello, World! appear on the next line. You've just written and executed your first Python program.

Lesson image

When you run the command, the Python interpreter reads your .py file, understands the instructions you wrote, and carries them out. In this case, it executed the print() function and displayed the text.

Now that you've got the basics down, let's test your knowledge.

Quiz Questions 1/5

What is a core design philosophy of the Python programming language?

Quiz Questions 2/5

Which line of code will display the text Hello, World! on the screen?

Congratulations on taking your first step. With Python installed and your first program running, you're ready to explore what else this powerful language can do.