The very first print in a long journey of printing phrases, automating tasks, and everything between – Hello, Python! This window is a demo of Python “IDLE” terminal that can be downloaded from python.org for “Interactive mode” or immediate code execution like the Hello World print code seen above!
This is going to be a mix of Programming Languages in general, Terminology, and at the end more Python specific – So this may be a long ranty sort of post but I want this info documented for later reference.
This article is going the be a bit chaotic as the information is coming in weird bursts that I’m having trouble properly finding a good flow for, so bare with me for this post 🙂
What makes Python Python?
- It runs on anything, Windows / Apple / Linux / Phones / Light bulbs (IoT anyone?)
- It is Open Source which means it does not need to be licensed for Enterprise use, can be paired with Open Source programs that run Python to create powerful tools that cost absolutely nothing to the company
- It is Object-Oriented Programming meaning it is logical, it makes sense to the human brain (readable) over other coding languages such as Ruby
- Broad community support among developers
So its an Open Source / Free Unlicensed coding language that is flexible to use in almost any application, which is used from Hobbyist Coders to Universities and Enterprises.
Programming Languaged VS Scripting Languages
Programming languages are high level “traditional” languages such as C / C++ / LISP / Etc, and one big difference from a Scripting language is that they must be “Compiled” into “Machine Code” that the PC understands, which is Platform specific.
This means if you write in C++ for a windows specific application, it will not work on Apple or Linux, Programming Languages are compiled for specific platforms.
The high level or “raw” scripted language is sent to the Client which does the compile / link / machine code conversion, making it platform independent, as the code is interpreted by the Client receiving the code which figures out how to understand it.
This convenience does come with the trade off of both degradation of performance as the client is doing the unpacking / conversion of raw code sent to it, and also security in sending raw code that could be intercepted in transit to the client.
Python is surprisingly neither of these, but rather an “Intermediate” language
Looking at Programming and Python Terminology and concepts
“Logically Malleable” is a word I see a lot that means that something is flexible to be used to accomplish many different tasks it was not designed to accomplish.
One very basic concept or example of a program is clicking a mouse on a PC screen to open a file, someone had to create a code to tell the mouse how to move per the input it gets from its ball roller (old school mice) or laser input, and what to do with Left-Click and Right-Click functions.
What problems does Programming solve in the IT World?
When coding to instruct computers to perform functions, there is no room for ambiguity of what function you want performed exactly, as computers will not assume something is implied within a code execution – It has to be explicitly and exactly stated to the PC.
Machine Code = Assembly Language as the PC understands it, which is barely readable.
High-Level or Human Legible is the language that we as developers write code as, that gets turned into Machine Code / Assembly Language using Compiling to convert code.
Python specific information regarding coding / code and file formatting
Python using this “Bytecode” language will save raw Python files as .py and Bytecode or partially compiled files will come out as .pyc to be exported to different platforms to use.
https://python.org is your resource for Python download, support, etc.
Python works in two modes:
Normal Mode – Creates .py and .pyc files
Interactive Mode – Immediate Execution of Python code (This is the terminal)
You can see which version of Python you have loaded onto your OS via the native Terminal, in which you can actually launch Python as well, or use Python “Idle” which is a Python terminal itself that launches directly into Interactive Mode where you execute codes immediately as demonstrated below with a “Hello, World!” print 🙂
From the Native Terminal on your Operating System:
To see your version of Py installed (or if its installed at all) : python -V
To go into Python coding mode within the native terminal : python
Windows 10 OS:
Linux Ubuntu 18.x:
As seen my Linux Ubuntu VM is still running the natively installed Python 2.7, as Python does come natively installed (older version) on some OS’s, however I’ll have to see about getting that upgraded as the ‘sudo apt install python3’ seems not to be working.
And then there is the Python Terminal Program available at python.org “IDLE” :
I really like this shell as it dynamically changes colors to let you know how the line of code is doing format wise, like when I typed the ( and ‘ in (‘Hello, World!’) it turned a shade of color until I closed the hyphen and parenthesis, Visual Studio Code which I usually hear referred to as VS Code is very good at this as well but you must load a .py file into it for editing from my current understanding (I haven’t played with it much).
VS Code is an example of working in “Normal Mode”, while the colorful terminal interface Py “IDLE” is an example of “Interactive Mode” as we are executing codes and getting immediate output from the code.
So now I am in “Interactive Mode” in the Py Terminal above, lets rock!
I won’t fill the page with examples of how it dynamically changes code color in Py IDLE, but highly advise playing with vs your Native Terminal, as the vibrant colors I think just makes it a little more enjoyable as well to as a coding environment / terminal.
One very basic concept I learned long ago is “Variables” which I am sure I will cover in much greater detail later, along with the single and double quotes called “String Literal”s that can be seen below doing their job in both functions:
print (y) will print the Variable associated with y.
print (“y”) will print the literal contents within the quotes – Hence “String Literal” 🙂
Note regarding “Variables” in Interactive mode – These are contained in a sort of cached state for the Interactive Mode session of Python coding, so they will be lost upon closing the terminal if not written to a .py file before closing the terminal.
Now the Terminal / Interactive Mode is good for playing around / testing lines of Code, but to write an actual chunk of Python Code you will need a text editor, I will be using Visual Studio Code to write my Python code in:
This is an amazing Text Editor that has extensions (and recommends them seen ^^^^^^ in this lower right corner of the image, if it detects your code needs further components to run it will offer to download them directly.
Visual Studio Code will integrate with your GitHub Repository to do GIT functions “Push / Pull / Merge / Etc” code at any time, from any PC in the world, you can work on projects yourself or collaborate via GitHub and this program links directly to it.
I didn’t end up getting this game to work, this was copy / pasted from:
https://www.pythonforbeginners.com/games/ – This is raw code to setup for games you can play in Python, nothing amazing as its text, but cool like TI-83 Calculator game programming back in the day (if you are as old as dirt like myself).
That will do it for this intro into Programming and Python!
Time to dig into Python, but there are some very important concepts there such as Compiling code / Linking Code / Interpreters for Scripted code / Etc that is very important to know for a baseline of coding knowledge before getting into deep into Python.
Next up will be variable, we are on the Python warpath, stay tuned! 🙂