Just Enough Python 1
Python is a great language to learn whether you're an absolute beginner or you have had some previous programming experience.
And Geany is a great program editor that lets you build and run Python programs from within the editor.
Both Python and Geany are included, by default, in the Raspbian operating system as well as being available for most other flavours of Linux.
So, if you are a beginner you should start right here at the beginning. And if you already have some programming experience, well, maybe you should start at the beginning, too, because Python is a bit different to other languages that you may have used before.
This is going to be a very quick tutorial just to get you started with Geany. We can move on to programming with Python properly, later.
Working with Geany
As I said Geany comes with Raspian, just go to the programming menu and click on the little lamp.
When you've done that you'll get Geany with a blank file already loaded. (In the future you will get the last file you were working on.)
It will look something like this...
The big window is the editor where we can type in our program. So type in
as you see below.
Now we need to save the file. Go to the file menu and select "Save as"
Navigate to your Documents folder and you should see that there are already some folders there. (Don't worry if your system is different to what you see below, we are going to create what we need.)
We will now create a folder for our Python programs called "Python Projects", so click on the "Create Folder" button.
Now type in the name of the folder "Python Projects"...
And now change the name of the file to hello.py...
Now click the "Save" button.
You'll see that the contents have changed. Because you have given the file a .py extension, Geany recognises it as a Python file and colours the various parts diferently. We will see that this can be very useful.
Now we run the program. Find the paper plane symbol and click it...
A terminal window will pop up and the hello.py will run in it. It just prints "Hello" as you knew it would.
Right, that was really quick, but now you know the basics of how to use Geany to write a Python program, and then run it.
Next time we'll begin programming, for real.
You can find the next tutorial here.