Welcome to the first part of an ongoing series: Learning Python!
In this lesson we will be setting up our coding environment and making our very first program!
(source)
First, we need to download Python.
All of my download instructions are for Windows, as I do not have access to Mac or Linux. A quick internet search can find installation instructions for most operating systems.
Before you go to download Python, make sure you know what your system's bit rate is. Very easy instructions can be found here.
(source)
Which version should I use?
As the owners of Python put it, "Python 2.x is legacy, Python 3.x is the present and future of the language." Python 3 was introduced in 2008 and Python 2.7 was released in mid 2010. Python has stated that they will not release any further updates to the 2 version. With that being said, Python 3 has resolved many "quirks" that could be confusing or unnatural to beginning programmers that Python 2 had. With these "quirks" in mind, you can see how different modules (code packages that allow you to use special features like a GUI) may not be updated to Python 3 as they would have to rewrite certain parts of their module to compensate for the absence of these "quirks." Python 3 is the most up to date version, with the absence of many "quirks," but has a lesser module selection to chose from.
I recommend using Python 3.5+.
Download
The link to the version I am using is here. From that link scroll down to the "Files" section and chose the version of Windows you are using with the part that says "executable installer." -A note on the Windows version: x86-64 is for 64 bit operating systems and x86 is for 32 bit operating systems.
After the download finishes, go ahead and open the executable. It will most likely ask you for Admin permission, and given that this is a trusted site and you know what you downloaded, allow it access. Then the installation options will come up to ask you where you want to install Python. I recommend the default location, and I have done that myself. Now you have Python!
Next, let's start coding!
To open your coding environment, go to the start menu and type in "Python" without the quotes. That will bring up at least three options, the environment that will be used in this tutorial is called IDLE. (You can use any Python IDE you want to, but all examples will be in IDLE.) IDLE will open and show you the coding console; from there you need to use File > New File, to start coding. It will open your coding area in a new window.
Finally, the first lesson!
Our first lesson is about the print statement! The print statement is used for printing to the console. It is a popular tool for debugging and giving you an idea of what your code is actually doing. The print statement is constructed simply by writing print immediately followed by what you want to print out in parenthesis. (I have heard that in some cases parenthesis are not necessary, but it is good coding practice to use them)
Now, what can you print to the console?
You can print text, numbers, and pretty much anything that can be saved as a variable. To use text it MUST be surrounded by double quotes! The double quotes tell the computer that this text is not a command it needs to follow, or more technically, they tell the computer that this text is a string. So onto our first example:
print("Hello, World!")
Let's run our code to see what it can do.
To run the code, go to Run > Run Module. It will ask you to save your code if there are unsaved changes. After you save, the program will run and you will have completed the first lesson in Python programming!
Previous Post
Thanks, very interesting!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Many programs still rely on Python 2.x only. That's why I would not throw away Python 2.x too fast (it really depends on what you want to do).
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
noice
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit