Introduction to Coding
Introduction to Python
What is Python?
Python is a programming language, a way for us to give instructions to a computer. What makes it special is its design philosophy, which emphasizes code readability with its simple, clean syntax. It's often recommended for beginners because it reads a bit like plain English, which makes the learning curve less steep.
The language was created in the late 1980s by Guido van Rossum. Fun fact: he named it after the British comedy group Monty Python!
Python is incredibly versatile. Think of it like a Swiss Army knife for programmers. It's used for building websites and apps, analyzing data, automating repetitive tasks, and even in artificial intelligence and machine learning. Its wide range of applications is one of the key reasons for its immense popularity.
Getting Python on Your Computer
To start writing Python, you first need to install it on your computer. The process is straightforward and varies slightly depending on your operating system.
On Windows:
- Go to the official Python website (python.org) and download the latest installer.
- Run the installer. Make sure to check the box that says "Add Python to PATH." This is important because it allows you to run Python from your computer's command line.
- Follow the on-screen instructions to complete the installation.
On macOS:
macOS often comes with an older version of Python pre-installed. However, it's best to install the latest version. You can download the official installer from python.org, just like on Windows. Alternatively, if you use a package manager like Homebrew, you can install it by running brew install python3 in your terminal.
On Linux:
Most Linux distributions come with Python pre-installed. You can check the version by opening a terminal and typing python3 --version. If you need to install it or upgrade, you can use your distribution's package manager. For example, on Ubuntu or Debian, you would use sudo apt-get install python3.
Your Programming Workspace
While you can write Python code in a simple text editor, most developers use an Integrated Development Environment, or IDE. An IDE is a software application that provides comprehensive facilities to programmers for software development. It normally consists of a source code editor, build automation tools, and a debugger.
For beginners, we recommend an IDE called Thonny. It’s designed specifically for learning and teaching programming, so it has a very simple, clean interface. It also comes with Python built-in, so you don't have to install it separately if you use Thonny's installer. You can download Thonny from its website, thonny.org.
Writing Your First Script
Let's write your first piece of Python code. It’s a tradition in programming to start by making the computer say "Hello, World!".
Open Thonny. You'll see a text editor at the top and a command area, called the Shell, at the bottom. In the text editor, type the following line of code:
print("Hello, World!")
This line uses the print() function, which is a built-in Python command that displays text on the screen. The text you want to display goes inside the parentheses and quotation marks.
Now, save your file. Go to File > Save and name it hello.py. The .py extension is important as it tells the computer that this is a Python file. To run your script, click the green "Run" button (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 written and executed your first Python program.
Now that you have your environment set up and have run a basic script, you're ready to dive deeper. Let's test what you've learned.
What is a primary reason Python is often recommended for beginners?
When installing Python on Windows from the official installer, what is the crucial step mentioned to ensure it can be run from the command line?
You've taken the first crucial step into the world of programming. Keep experimenting with the print() function and get comfortable with Thonny. In the next section, we'll explore some of Python's fundamental building blocks.


