Usually, when we think of religious orders, these things come to mind: a cloister, an abbey, a library, prayer in solitude, detachment from the world… All this in the cradle of a period defined as "dark" by historiography up to Romanticism: the Middle Ages . In this period the monks - especially the Benedictines of the various orders - were the custodians of Judeo-Christian but also classical culture, since thanks to their patient and meticulous transcriptions as scribes we have received almost all of the Greek and Latin works which we study today. Today we are grateful to them first of all for this. However, many do not know that many products - material and immaterial - that we consume and use every day, come from monks who, using their ingenuity nourished by a profound spirituality, invented them due to practical necessities. Personally, I find it amazing! Let's begin… The heavy plow Plows were a primary agri...
Introduction
Recently more and more people are gaining interest in better understanding what a programming language really is. Today, I’m going to help you understand the basics of programming languages by explaining it with secondary school Math knowledge (functions and equation systems).
To make the job as easy as possible, I chose one of the easiest programming languages out there, which is also the one commonly used to introduce people to the coding world nowadays: Python!
Before starting: I’m “considering” all the code I’m writing as a “superset” of Math, meaning that every basic operation and operator valid in Math is also valid in Python: for example 1 + 1 is 2 and valid in Math, but also in Python, so you can use +-*/ and parentheses as normal, excluding some exceptions like ^, equal sign, parentheses different from round brackets, etcetera, but don't worry, we’re doing basic things for now!
Knowing what a function is in Math, let's imagine you already defined a function called “print”, which prints (shows you, reports you, logs you) the result of the argument you passed in it.
I know, most of the time the functions you see only have a single letter as their name (ex. f), not an entire word… but it’s ok to use both in Math and programming a function with more than one letter.
Here’s the function, with some examples…
I know this function is kinda ridiculous, but it isn’t at all: differently from Math, where we calculate everything and then write down the result, a machine doesn’t know what to “tell” you after it completes all these calculations so you have to instruct it.
Notice also that I’ve already included the example of print(1+2): in fact, this is the same thing you can do in Math, by passing an expression instead of a value inside the function.
Variables
You probably encountered hundreds of them in Math problems, but I’m going to give you a (really) basic example: “Given the function f(x) = x + 1, let x be 1” (which gives 2 as result).
Ok, now let’s implement the same thing in Python, by printing the result of “x + 1”, setting x to 1…
Again, this seems obvious, but in order to get you on the computer’s side, let’s analyse the step taken:
- letting x be 1 (this is a variable! You defined x to be 1!)
- solving the steps required to get a value from the expression inside the print function, which are replacing x with the actual value, which is 1, and adding 1 + 1, which is 2
- last but not least, “writing down” (outputting) the result because print(2) is left: the result is… 2!
Now it’s your turn!
Open this website.
Ignore whatever it’s written there, press CTRL+A (or CMD+A) to select everything and Backspace to remove all the content. Now try writing print(1) (as in the box 1 of the image) and press the Run button (2) below the text box.
After the execution (takes about 1 sec.), you should see 1 in the output (3).
Now that you have a bit of manual skill with the Python Interpreter (we call the website “interpreter” as it “interprets” Python code and executes it)...
Here’s a problem for you to solve with Python:
“Let a to be 2 and b to be 3. Given y = 5a + 2b + 7, what is the value for y?”
(Tip: in Math, this would be a system of equations with 2 unknowns... that you already have!)
Looking for the solution? Find it on the second part of the article!
Today’s Blogger
Hi, I'm Giorgio Bellisario, a Liceo Scientifico student. My passion revolves around tech and everything computer-related. Coding is my favourite hobby, and I primarily focus on web development, crafting websites from scratch. If you're intrigued by all things tech and ethical "hacking", you've come to the right place.
Comments
Post a Comment