You need Python! And, when it is not installed on your computer, this post is for you. The instructions are for Windows users, because mac users have Python pre-installed and Linux users can figure out how to install Python on their own.
Go to the Python website and download the latest Python version. Currently, there are two major Python versions. The old Python, which is version 2.7.xx and the new Python 3.xx.xx. A lot of external libraries did not yet get a compatibility update for Python 3, so I use Python 2.7. More information about the differences between the two Python versions can be found here.
Once you’ve downloaded the installer msi-file, run the file and choose to Install it for all users. In the Select Destination Directory window, you have the option to choose where to install Python. I prefer to install it in C:\Python27\. This is a clean path without any spaces, which will make life easy when we start coding. Continue the installation until it has finished.
Now you have Python installed on your computer, but the system does not know where to find the Python executable yet. You will need to add two paths to your system path variable. And of course, windows makes that so easy that it is just 25 clicks away. Therefore, I made a video tutorial, so you can easily follow my instructions.
Now we know that we can run Python, we want to create our first Python script. Create a new text file on your desktop and call it ‘MyFirstScript.py’. Edit the file and add the following code:
print 'Let us create a truly unique program...' print '...' print '...' print 'Hello, world!' print '...' output = raw_input('Was this satisfying? (Y/N)\n') print '' if output == 'Y': print 'Thanks' elif output == 'N': print 'Tough crowd...' else: print 'Following instructions is not your strength...'
This small program prints a message, asks a user for input and then responds based on the user input. To run your program, we need to start the cmd where we created the Python file. I told you to do this on your desktop, so we will start a cmd there. The easiest way to start a cmd in a certain folder is to shift-right-click in that folder and then choose ‘Open command window here’.
In the cmd window, type python MyFirstScript.py and press enter. The program will ask you a question and you can answer with Y or N. Confirm your answer by pressing enter and the program will respond. You just created your first Python program!