What You Will Need to Code With Python
A Computer – Obviously you’re going to need a computer in order to learn how to program in Python and to test your code. You can use Windows (from XP onward) on either a 32 or 64-bit processor, an Apple Mac or Linux installed PC.
An IDE – An IDE (Integrated Developer Environment) is used to enter and execute Python code. It enables you to inspect your program code and the values within the code, as well as offering advanced features. There are many different IDEs available, so find the one that works for you and gives the best results.
Python Software – macOS and Linux already come with Python preinstalled as part of the operating
system, as does the Raspberry Pi. However, you need to ensure that you’re running the latest version of Python. Windows users need to download and install Python, which we’ll cover shortly.
A Text Editor – Whilst a text editor is an ideal environment to enter code into, it’s not an absolute necessity. You can enter and execute code directly from the IDLE but a text editor, such as Sublime Text or Notepad++, offers more advanced features and colour coding when entering code.
Internet Access – Python is an ever evolving environment and as such new versions often introduce new concepts or change existing commands and code structure to make it a more efficient language. Having access to the Internet will keep you up-to-date, help you out when you get stuck and give access to Python’s immense number of modules.
Time and Patience – Despite what other books may lead you to believe, you won’t become a programmer in 24-hours. Learning to code in Python takes time, and patience. You may become stuck at times and other times the code will flow like water. Understand you’re learning something entirely new, and you will get there.
Starting Python for the First Time
We’re using Python 3 under Windows 10 for these following examples. Don’t worry if your version of Python is 3.4.2, or something lesser than the current version, as long as you’re using Python 3, the code will work. As when learning anything new, you need to start slow. You can pick up the pace as your experience grows, but for now, let’s just get something appearing on the screen. Don’t worry, you’ll soon be coding like a pro!
Step 1 – Click on the Windows Start button, and start typing ‘idle’. The result will be the currently installed
version of Python, IDLE (Python 3.7 32-bit), for example. You can Pin it to the Start for convenience, otherwise simply click the icon to launch the Python Shell.
Step 2 – The Shell is where you can enter code and see the responses and output of code you’ve programmed
into Python. This is a kind of sandbox, if you will, where you’re able to try out some simple code and processes.
Step 3 – For example, in the Shell enter: 2+2 After pressing Enter, the next line will display the answer: 4. Basically, Python has taken the ‘code’ and produced the relevant output.
Step 4 – The Python Shell acts very much like a calculator, since code is basically a series of mathematical interactions with the system. Integers, which are the infinite sequence of whole numbers, can easily be added, subtracted, multiplied, and so on.
Step 5 – While that’s very interesting, it’s not particularly exciting. Instead, try this:
Just enter it into the IDLE as you’ve done in the previous steps.
Step 6 – This is a little more like it, since you’ve just produced your first bit of code. The Print command is fairly
self-explanatory, it prints things. Python 3 requires the parentheses as well as quotes in order to output content to the screen, in this case the ‘Hello everyone!’ bit.
Step 7 – You’ll have noticed the colour coding within the Python IDLE. The colours represent different
elements of Python code. They are:
Black – Data and Variables
Green – Strings
Purple – Functions
Orange – Commands
Blue – User Functions
Dark Red – Comments
Light Red – Error Messages
Step 8 – The Python IDLE is a configurable environment. If you don’t like the way the colours are represented,
then you can always change them via Options > Configure IDLE, and clicking on the Highlighting tab. However, we don’t recommend that as you won’t be seeing the same as our screenshots.
Step 9 – As with most programs available, regardless of the operating system, there are numerous shortcut
keys. We don’t have room for them all here, but within the Options > Configure IDLE and under the Keys tab, you’ll see a list of the current bindings.
Step 10 – The Python IDLE is a power interface, and one that’s actually been written in Python using one
of the available GUI toolkits. If you want to know the many ins and outs for the Shell, we recommend you take a few moments to view https://docs.python.org/3/library/idle.html, which details many of the IDLE’s features.
Ready for more? You can learn how to start writing and executing your first code here.