PYTHON BEGINNERS GUIDE INTRODUCTION
Python Beginners Guide introduction is aimed at first-time users of Python. However, it will lean towards teaching techniques that help when moving to another language. So why program in Python? Python has a simple syntax compared to many other programming languages. It can be easier to get to grips with for first-time coders. Python has many data science libraries that other languages don’t. For many students, the reason is more straightforward; it is the language chosen by most high schools (in the UK). Unfortunately, the simplicity of the language sometimes means students miss concepts that a different language would force them to understand. I have started writing this guide to try and address those misconceptions. Python is universal; it can be run on Windows, Mac, Linux, Android and IOS.
A first look at Python Code – Hello World
Hello, World is the classic first look at a coding program. The program outputs the words “Hello World” to the screen. In Python, this is a single line of code.
So how do you get started with Python? There are several ways of doing this. First, Python can be installed on your computer. However, many websites will let you write and run Python Code within a browser.
Running Code In a Browser
There are many choices, but one I have seen many recommend is replit. Replit has a friendly interface where you code in one window, and the output of the code runs in another window. Additionally, it supports other languages. Working in a web browser is absolutely fine for beginners. When using multiple files, it is essential to use an installed version.
Running Python Code on your Computer – Python Beginners Guide Introduction
Installing Python On Your Computer
I will add my own guides on how to set up Python later. Meanwhile, Digital Ocean already has several guides for Windows (Windows 11 is exactly the same) and Ubuntu Linux. There are several guides online for Mac, however. However, I do not own a Mac, so I couldn’t test them. The official python documentation has a Mac Install Guide; however, the language is technical. Additionally, there are some videos on Youtube, such as How to Install Python 3 on Mac OS X.
Install Python On Windows Video
Using Idle Shell
The Idle shell window lets you write code one line at a time. For example, try writing the hello world program above into the shell window and then click enter.
Note how the code changes colour as you type. That is called syntax highlighting. It helps make your code readable and lets you know when you have typed in a Pyth n command. The colours vary from one IDE (Integrated Development Environment) to another. However, the principle remains the same. The colours break up the code into sections.
Idle Script Mode
Typically when writing a program, it is necessary to write more than one line of code at a time. Idle comes with a script mode editor for this purpose. First, go to the file menu in the shell window, then click “New File.”
Second, set up the windows side by side so that you can see the shell and the script window at the same time.
Next, write a couple of lines of code in the script window. For this first test, just write the hello world program twice. Finally, click the F5 key to run the code. It will ask you to save the file; this is necessary for the program to run.
Alternative IDE’s – Python Beginners Guide Introduction
Many companies are offering an IDE to help write Python Code. The list below contains some of the more prominent names. There is no particular order to the list, and its presence doesn’t mean I recommend them. Each has its own strength and weakness. I encourage you to try them and make your own judgement.
I would wait until you have written at least a few small programs before trying the alternative IDEs. As a developer, I would never write my code in Idle. There are many benefits to choosing PyCharm or Visual Studio. However, those benefits come with complexity. Both programs have enough options to overwhelm new programmers without guidance in their first use.
- Jetbrains PyCharm – Professional IDE is a little complicated to set up. Does come with an education and community licence.
- Microsoft Visual Studio – Professional full-fledged IDE for multiple languages. Complicated but very powerful. Does come with a free community version.
- Microsoft Visual Studio Code – Free editor and IDE from Microsoft. Will need a python extension installed.
- Thonny is an IDE from the University of Tartu designed for beginners. Download here.