An Introduction to Python for Non-Programmers – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn An Introduction to Python for Non-Programmers – InApps in today’s post !
Read more about An Introduction to Python for Non-Programmers – InApps at Wikipedia
You can find content about An Introduction to Python for Non-Programmers – InApps from the Wikipedia website
Welcome to the first entry in this Python for non-programmers series.
If you’re reading this, you probably have developed a curiosity about programming and are looking for a good place to start. I have good news for you. Python is one of the best languages with which to start that journey. Why? We’ll get into that in a minute. But first, let’s discover exactly what this language is and can do.
Python is what’s called a high-level, general-purpose programming language. Let’s break that definition down.
First, what is a high-level language? Let’s consider this:
At the bottom, you have the computer hardware, which only understands what’s called “machine language.” Because machine language (or machine code) is so close to the hardware, it’s considered a low-level language (because it exists at such a low level).
As you rise up away from the low level, languages become high-level, because they are abstracted away from the hardware. High-level languages do not need to view or access the details of the computer. If they did, they’d be considerably harder to use.
- Are programmer-friendly and easier to understand.
- Are less memory efficient.
- Are easier to debug.
- Are relatively easy to maintain.
- Are portable (so they can run on any supporting platform)
- Require a compiler or interpreter.
- Are widely used.
So Python being a high-level language already gives it a head start on user-friendliness.
Our next definition is general purpose. A general-purpose language is a computer language that is used to solve a wide variety of problems. In other words, you can use a general-purpose language for many things.
Put those two things together and Python is a programming language that can be easily used for several purposes. But Python isn’t just easy to use because it’s a high-level language.
What Makes Python so Easy to Use?
One of the main reasons why Python is so easy to use is because it reads almost like the English language. Python has a very clear and simple-to-understand syntax that is used for web developers, desktop developers, game developers, data scientists, and more. With Python so widely-used, it has a very large community, so help is never far away.
So, Python is easy to read, used everywhere, and has a vast community for support. In fact, of all the programming languages, Python is almost always considered the easiest to learn.
The picture is becoming clearer and clearer.
With all of that said, let’s introduce ourselves to Python.
Another thing that sets Python apart from a number of other languages is that it’s an interpreted language. This means Python doesn’t need a compiler, so you write the code and run it. Now, that also means you must have Python installed. If you didn’t have python installed, if you created the file hello-newstack.py, it would be of no use. However, with Python installed, you could create the file, add the code, and run it (without having to first compile it).
Let’s walk through this very simple example.
Hello, New Stack!
One of the most widely-used examples (for nearly any programming language) is the Hello, World! example. This simple application does one thing — it prints out a line of text in the terminal. To do that, Python uses what’s called a function, which is a set of instructions that has been previously bundled together that achieve a specific outcome. This means the programmer doesn’t have to create everything.
Let me explain that a bit more simply. Let’s take Legos. When you buy a set of Legos, it’ll come with a bunch of bricks that you can use to form objects. But within that kit, you’ll also find special pieces that can be used to build particular things. For example, you’ll find heads, hands, torsos, arms, and legs which make it easy to build Lego people. Imagine how much more time it would take if you had to build those people out of the included Lego bricks. Not only would it be more challenging, but the people also wouldn’t look as much like people (and more like blocky robots).
Think of those special “people parts” as functions. You could also consider specialized pieces that make it easier to build cars, planes, rockets, or the International Space Station as functions.
Back to our example.
With the Hello, World application, we only need to make use of one function,
print(), which tells the interpreter to print out what’s housed between the (). So with our Hello, New Stack example, that function would be used like so:
print('Hello, New Stack!')
That’s a line of Python code. More to the point, that’s the only line of Python code you need for the Hello, World example. Of course, good developers also document their code, so instead of just adding that one line, we’d preface it with something like:
#Print out the text “Hello, New Stack!”.
Let’s put that together. Open a terminal window and create the new file with the command:
In that file, paste the following:
#Print out the text “Hello, New Stack!”.
print(‘Hello, New Stack!’)
Save and close the file with the [Ctrl]+[x] keyboard shortcut.
Remember when I said a python file (a file that ends with .py) isn’t any good without Python installed? Let’s install it. I’ll demonstrate on Ubuntu Linux 20.04. Back at the terminal window issue the command:
sudo apt-get install python3 -y
Now we can actually run our new Python application with the command:
The output of the command will simply print Hello, New Stack! (Figure 1).
Congratulations, you’ve taken your first steps with Python, and you did so without having to know anything about computer programming. In the next entry of this series, we’ll learn a bit more about the language and how to create an application that’s a bit more complicated.
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.