No history yet

Introduction to Python

What Is Python?

Python is a versatile and popular 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. Think of it as a language that prioritizes clarity, which makes it an excellent choice for beginners.

Lesson image

But it's not just for newcomers. Professionals use Python for a huge range of tasks. It powers websites and web applications, automates repetitive tasks, analyzes data, and is a key tool in machine learning and artificial intelligence. Companies like Google, Netflix, and Spotify all rely on Python for various parts of their operations.

Getting Python Ready

Before you can write any code, you need to have Python installed on your computer. Many macOS and Linux systems come with Python pre-installed. To check, you can open your terminal (or command prompt on Windows) and type python --version.

If you don't have it or want the latest version, you can download it for free from the official Python website, python.org. The site automatically suggests the best version for your operating system, whether it's Windows, macOS, or Linux.

Windows users: During installation, make sure to check the box that says "Add Python to PATH." This allows you to run Python from your command prompt easily, no matter which folder you're in.

Once the installer finishes, you're all set. You now have the Python interpreter on your machine, which is the program that reads and executes your Python code.

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 and gives you a first taste of the language's syntax. In Python, this is incredibly straightforward.

The classic "Hello, World!" program is a great place to start when learning a new programming language.

All you need is a single line of code using Python's built-in print() function. This function takes whatever you put inside the parentheses and displays it on the screen.

print("Hello, World!")

To run this, follow these steps:

  1. Open a plain text editor (like Notepad on Windows, or TextEdit on Mac).
  2. Type the code exactly as it appears above.
  3. Save the file with a .py extension, for example, hello.py. This extension tells your computer it's a Python file.
  4. Open your terminal or command prompt.
  5. Navigate to the directory where you saved your file. You can do this using the cd (change directory) command.
  6. Type python hello.py and press Enter.

You should see the text Hello, World! printed in the terminal. That's it—you've just written and run your first Python program.

Lesson image

Now you've got the basics down. Let's review what we've covered.

Quiz Questions 1/5

Who is the creator of the Python programming language?

Quiz Questions 2/5

What is the primary design philosophy of Python?

With setup complete and your first program running, you're ready to explore what else Python can do.