Introduction
Hello Everyone and welcome to my first lesson of a new series about the Python language. I have just finished a series on the Java programming language which can be found here https://steemit.com/programming/@robertlyon/java-programming-for-beginners-course.
This python course will cover the same format but will obviously be focusing on the Python language which although has similarities to the Java language, it is actually quite different and I would say a lot easier to learn.
In this first lesson, I will be covering how to set up your computer so that you have the tools to work with the python language and how to create and run your first Python program which will be a simple Hello World application.
So let's dive straight in.
Installing Python
To find the download for the latest version of Python you will have to go to the Python Website which can be found below
https://www.python.org/downloads/
This link will bring up a webpage that looks like the one below.
Figure 1. Download screen on the Python website.
As you can see above I have added a print screen of the downloads page on the official Python website. On this page, you will want to download the latest version of the software which is marked out with a red circle. Also, take note of the second red circle. If you have a do not use Windows then you can find the download file for your own OS.
After you have downloaded the installer you need to execute the installer, you can then execute the program. The first screen you will be presented with is the one below.
Figure 2. Python install wizard screen 1
On the screen above, click Install Now which is shown by the red circle.
After you have clicked Install Now, the install wizard will install all of the necessary Python files and you will be presented with the following screen.
Figure 3. Python install wizard screen 2
This window just tells you that the install was successful, click on the close button marked by the red circle to carry on.
After pressing close, use the search feature of your operating system to search for IDLE, this is the IDE that comes standard with Python and it is the one which we will be using for the remainder of this series.
Figure 4. Searching for the Python IDLE
Once you have clicked on the idle application you will be presented with the following screen.
Figure 5. The Python Shell
The program in the image above is named the Python Shell, you can think of this like the command line, this is where your program will run and will become more apparent throughout the series.
Now you are going to start writing your first Python program.
Hello World Program
To start this program we need a text editor. Luckily the Python IDLE program contains a text editor to access that we need to go to file and click new file(alternatively you could press "Ctrl + N"). See image below for a demonstration.
Figure 6. Creating a new file.
Now we will write out the program. If you are familiar with my Java tutorial series or a language such as C++, you will see how much simpler Python is for creating small programs such as this. Have a look at the image below, the syntax is fairly self-explanatory but I will cover the key points.
Figure 7. Hello World program
As we can see above this program only consists of 1 single line. The function print()
in python prints out whatever is contained within the parentheses to the console which we can see in the next two images below which will show you how to execute the program.
Figure 8. How to run a Python file in the shell
Figure 9. Output from a Hello World application
As you can see above, while you are on the text editor screen you go to the run menu and click on run module(or you can just press F5).
On the second image, you can see that the program has printed out the string value "Hello World" to the Python shell.
Congratulations you have just created and run your first program.
Conclusion
This program was designed just to be a very simple introduction to the IDLE program for python and a test to make sure that the language was downloaded and installed properly on your machine. Hopefully, you now have the python language and the IDLE program installed on your computer and you are now able to run Python programs.
Look forward to my next lesson on variables.
As always if there are any improvements you think I can make to this post then please leave a comment and I will consider adding it.
Thank you for reading and I hope that someone will get some use out of these tutorials.
Message to readers
Thanks for taking the time to read my post, if you are interested in Science, Technology or Computer Science then check out my blog, content is a little sparse at the moment but I am making an effort to provide good quality original content to the Steemit community.