No history yet

Introduction to Python

What is Python?

Python is a high-level programming language known for its simple, readable syntax. It was created in the late 1980s by Guido van Rossum, who wanted to design a language that was easy to read and write. The core idea is that code should be as clear as plain English.

Lesson image

Unlike some other languages that require complex symbols and structures, Python uses clean indentation and common words. This makes it a great starting point for beginners. It's an interpreted language, which means you can run your code line by line and see the results immediately, making it easier to test and debug ideas.

Where You'll Find Python

Python's versatility makes it a powerhouse in many industries. Its simple syntax and powerful libraries—collections of pre-written code—allow developers to build complex applications quickly.

Here are a few common uses:

  • Web Development: Frameworks like Django and Flask are used to build the server-side logic of websites and web apps. Instagram and Spotify, for example, use Python extensively.
  • Data Science and Machine Learning: Python is the go-to language for analyzing data, creating visualizations, and building machine learning models. Libraries like Pandas, NumPy, and TensorFlow are industry standards.
  • Automation and Scripting: If you have a repetitive task, you can often write a simple Python script to do it for you. This can be anything from renaming thousands of files to filling out online forms.
Lesson image

Getting Started

Before you can write Python code, you need to install the Python interpreter on your computer. This is the program that reads your code and carries out its instructions. We'll be using Python 3, which is the current and actively developed version of the language.

You can download the official installer from the Python website at python.org. The installation process is straightforward for Windows, macOS, and Linux.

Lesson image

Once Python is installed, you need a place to write and run your code. While you can use a simple text editor, it's much easier to use an Integrated Development Environment, or IDE. An IDE is software that combines a text editor, a code runner, and debugging tools into one application.

Your Coding Environment: Thonny

For beginners, we'll use an IDE called Thonny. It was designed specifically for learning to code. It has a very simple interface and includes helpful features that show you what's happening inside your program as it runs.

Lesson image

Thonny comes with Python built-in, so you might not even need to install Python separately. You can download it for free from thonny.org.

After installing and opening Thonny, you'll see two main areas: the editor (where you write your code) and the shell (where you see the output). Let's write our first program.

Type the following line of code into the editor—the large, main window at the top.

# This is your first Python program
print("Hello, World!")

The line starting with # is a comment, which Python ignores. The print() function simply displays whatever is inside the parentheses on the screen.

To run your code, click the green "Run" button in the toolbar (it looks like a play symbol). You should see the text "Hello, World!" appear in the shell at the bottom of the window. Congratulations, you've just run your first Python program!

Quiz Questions 1/5

What is the primary design philosophy behind Python's syntax?

Quiz Questions 2/5

Python is described as an interpreted language. What does this mean?