Python is, in my opinion, the perfect programming language for learning how to code with no experience whatsoever. The code is both simple to understand, yet can be built upon to create complex, exciting programs that are deceptively powerful.
I first learned how to code in Python back at college in 2007, and although I don’t use it commercially for any programming projects I work on, I regularly hold classes, lessons, and sessions with people all across the world who want to learn to program, using Python as my go-to starter language.
So how do you start working with Python? This is the easiest part – you only need to install it from the Python.org website, choose the operating system you are working on, download it and install it.
Download Python Here – https://www.python.org/downloads/
Once downloaded, simply run the installer, follow the prompts and messages that appear (the default options are usually good enough, but you are welcome to customise them if you want to). Once installed, you can start using Python straight away!
Opening Python IDLE – Multi-Line Issue Fixed!
IDLE is the program you use to type your code. You can open IDLE via your computer operating system (Start Menu for Windows, Launchpad for Mac, Apps for other Operating Systems. If anyone needs specific help on opening IDLE please leave a comment or get in contact).
Now, one small caveat with IDLE, when you first open the program, it is running in something called ‘Single Line Mode’. What this means is, every time you go to a new line, the code is automatically run, and will probably cause an error if you are trying to write a multi-line application. Not good!
To correct this, open IDLE, then using the menu across the top, select File > New File. This will open a blank console window and will allow you to write as many lines of code as you need.
This issue only happens when you start a new python file. If you are opening a pre-existing Python file, it should open in multi-line mode automatically.
Write Your First Program in Python
So, you’ve got the software, now you need to actually create something. I have seen so many people install software, and then never use it. Let’s get that barrier broken straight away by getting you to create a simple program right now!
In true programming fashion, your first program should be a simple line of code that reveals a message. Most people use the phrase “Hello World!” when doing this, but feel free to use your own phrase if you prefer.
So, here is your first program in Python:
- Open Python IDLE
- Go to File > New File
- Type in the following line of code, adjust if you prefer
print("Does anyone fancy a packet of Jelly Babies?")
- Using the menu across the top, select Run > Run Module
- Save your Python file in a suitable place with a suitable name, eg – save it in your Documents folder with the name ‘My first Python App’.
- Once saved, your code should automatically run, and you are greeted with a screen that displays the message you typed in.
Well done! You’ve just made your first Python application.
To close it, simply press the ‘X’ button on the screen that appears.
See, that wasn’t so bad was it? I’ll put together some more tutorials over time, and we’ll go through them all in detail. In a short space of time, you shall become a Python convert, taking slow but methodical steps every time to improve your skills as a programmer. You’ll be making complex systems in no time.
And so begins your journey down the rabbit that is Python and Programming. I hope you enjoy it, and see you next time for our first proper steps into coding.