No history yet

Introduction to Python

What is Python?

Python is a high-level programming language known for its readability. Its design philosophy emphasizes code that's easy to read and write, which makes it a popular choice for beginners and experts alike.

Created by Guido van Rossum and first released in 1991, Python's name was inspired by the British comedy group Monty Python. The language was designed to be powerful yet straightforward, handling complex tasks with simple commands.

Lesson image

One of Python's core principles is that there should be one, and preferably only one, obvious way to do something. This leads to clean, consistent code that is easier to maintain and debug.

Why Learn Python?

Python's simplicity doesn't limit its power. It has a massive standard library, which is a collection of pre-written code that you can use in your own programs. This means you don't have to start from scratch for every task, whether it's sending an email or fetching data from the web.

It's also incredibly versatile. Python is used in a wide array of fields.

Lesson image

Its applications range from web development (using frameworks like Django and Flask) to data science, artificial intelligence, and scientific computing. Companies like Google, Netflix, and NASA use Python extensively for everything from building web services to analyzing astronomical data.

Getting Started

To start programming in Python, you need two things: the Python interpreter and a place to write your code.

The interpreter is a program that reads your Python code and executes it. It goes through your code line by line and carries out the instructions.

An Integrated Development Environment (IDE) is a software application that makes writing code easier. Think of it as a specialized word processor for programmers. It includes a text editor for writing code, tools for running it, and features that help you find and fix errors.

IDE

noun

An Integrated Development Environment is a software suite that consolidates the basic tools developers need to write and test software.

For beginners, an IDE called Thonny is a great choice. It was designed specifically for learning and teaching programming. The best part is that it comes with Python already bundled, so you only need to do one installation.

To install it, just go to the official Thonny website, download the installer for your operating system (Windows, macOS, or Linux), and run it. The setup process is straightforward and will get you ready to code in minutes.

Lesson image

Your First Program

It's a long-standing tradition in programming to start by writing a program that simply displays "Hello, World!" on the screen. This simple task confirms that your setup is working correctly and gives you a feel for the language's basic syntax.

In Python, this is incredibly simple. You use a built-in function called print().

A function is a reusable block of code that performs a specific action. You "call" a function by writing its name followed by parentheses.

Open Thonny. In the main editor window, type the following line of code:

print("Hello, World!")

Here, we're calling the print() function and giving it one piece of information, called an argument: the text "Hello, World!". The quotation marks tell Python that this is a string of text.

Now, click the green "Run" button in the Thonny toolbar (it looks like a play symbol). You'll see the output appear in the "Shell" pane at the bottom of the window.

And that's it! You've just written and run your first Python program.

Quiz Questions 1/5

What is a core principle of Python's design philosophy?

Quiz Questions 2/5

What is the primary function of a Python interpreter?

You've taken the first step into the world of Python. Now you're ready to explore what else this powerful language can do.