Python Foundation
Python has become one of the most accessible and widely used programming languages in the world. It was created by Guido van Rossum in the late 1980s and released publicly in 1991. It is open source, and today it powers various applications including websites, scientific computing, artificial intelligence, automation, and more. This beginner's guide is designed for readers who have never written code before and will demonstrate some Python basics.

Why learn Python?
Python is often recommended as a first programming language because it emphasizes readability and simplicity. Its design encourages you to express concepts in fewer lines of code than languages like C or Java. Python is cross‑platform and can be used for web development, software scripting, mathematics and more recently it has become the de facto language of AI engineers worldwide. Python’s clean syntax and readability make it an excellent first language and understanding the fundamentals provides an excellent foundation of programming.
Major reasons to learn Python include:
Ease of learning: the language reads almost like English and does not require declaring variable types; the interpreter will infer types automatically.
Community and libraries: There is a vast ecosystem of packages (such as NumPy, pandas, Django and Flask) that help you build applications quickly.
Versatility: Python is used for automation, data analysis, web services, machine learning and robotics.
Modern improvements: Python 3.13 (released in 2024) offers a friendlier interactive interpreter with coloured prompts, multi‑line editing, recall of previous code blocks and improved paste behavior. Error messages now include coloured tracebacks and suggestions when keyword arguments are misspelled. These changes make learning Python easier than ever.
So what are you waiting for? Let’s get hands-on, and by the end of this guide you will be a programmer!
Setting up Python
Your computer may already include Python, but many systems still bundle Python 2. The official Python beginner’s guide warns that these older versions are outdated and recommends installing the latest Python 3. You can download installers for Windows, macOS and Linux from python.org. Alternatively, use your system’s package manager. You can even run Python on your iPad by using the Pythonista app.
On Ubuntu/Debian
On macOS, download and run the installer from python.org.
On macOS, install python with Homebrew:
On Windows, download and run the installer from python.org
After installation, verify the version from a terminal or command prompt:
Great! You now have Python installed.
Choose an editor or IDE
If you downloaded Python using the installer from python.org, you are provided with a simple environment that you can use to run Python code called IDLE. This will suffice for this beginner’s guide but as you progress on your journey you can use more powerful code editors such as VSCode, Pycharm, or Jupyter notebooks, all of which provide more comprehensive features for python programming.
You can also just use the command prompt to enter one or multiple commands to test code snippets quickly or generate output for your work. When it comes to more than a few lines of code, it's best to generate and save a program file separately (but more on that later).
The other option, at least on Linux and macOS, is to open a terminal window and type python at the command prompt. Doing so starts the Python command prompt, and you can start typing commands and running Python code.
The interactive interpreter (REPL)
Now that you have Python installed, it provides a read-evaluate-print-loop (REPL) when you run the command python or python3 without a script. If you have Python 3.13 installed, the REPL provides colored prompts, multiline editing and makes experimentation and testing of little scripts even easier.
Assuming you installed using an installer, open the IDLE shell by choosing it from your applications menu, and then try the following:
You should get the answer after you press enter: 4.
Let’s try something a little more fun, let’s use a for loop:
You should get the following output:
Great, you are on your way to becoming a python programmer!
Writing your first Python program
Python includes many built-in functions and you used one of them above called print() to display the output. Now, let’s take the command you ran in the REPL and convert it into a script that you can run as a program. In any text editor, create a file with the following contents and save the file as hello.py.
Now open up your terminal and navigate to where you saved the file, and then type the following into the command line: python3 hello.py.
You should get the response Hello, world! The first line in your file that starts with # is a comment and will be ignored by the interpreter. You should always included comments when you write a program as they help with debugging and will help you keep track of the code you write as you become a more proficient Python developer. Congratulations have just written your first python program!
Collections
Now that you know how to create variables and perform some basic operations on them, let’s look at another staple of computer science, the concept of a collection. In any program, you typically need to store information in a data structure and one of the most versatile ones that Python provides is the list. Lists are ordered and mutable collections that can hold multiple types of items in them.
You create lists with square brackets [], and you can add items, remove them, slice sub‑lists and iterate over them. Here are some key operations you can perform on a list. Imagine you have a list called lst the following describes what the following commands in python would perform.
Indexing:
lst[0]returns the first element; negative indexes count from the end.Slicing:
lst[1:3]returns a new list containing elements at positions 1 and 2.Appending:
lst.append(3)adds an element to the end.Extending:
lst.extend([4,5])adds multiple elements.Insert:
lst.insert(1, 'a')inserts at index 1;Delete:
del lst[0]deletes an element.
Let’s make a new file called lists.py and and paste the following lines into it:
Now open up your terminal and navigate to where you saved the file, and then type the following into the command line: python3 lists.py.
The output you should see from the terminal window should be like this:
List comprehensions provide a concise way to build lists by looping and optionally filtering; they are both readable and efficient. You should try to use them instead of lengthy loops when appropriate.
Functions
Functions are an important concept for anyone learning to program and will be a key way that you will use python modules in your hands-on experience with Python. Fundamentally a function is a process of breaking down a large programming task into smaller subtasks that allow you to declare logic in one place and then execute it in many. Python has many built-in functions and as you write your own functions you will likely import modules from a python library or your own code into your programs and execute them to keep your code clean and minimize duplication of logic.
I grew up in a place where celsius was the standard measure of temperature but now live in a place where fahrenheit is the standard measure. Let’s write a python function to help with the conversion of celsius to fahrenheit.
Let’s make a new file called functions.py and paste the following lines into it:
Now open up your terminal and navigate to where you saved the file, and type the following into the command line: python3 functions.py.
The output you should see from the terminal window should be like this:
In our functions above we are return values using the return keyword but if we don’t have a return function then Python will just return none if we aren’t expecting to provide anything back, normally this would occur if you were generating a log entry or writing something to a file.
Comments (0)
No comments yet.
