Here's the third article in our series dedicated to social media and how they affect our lives. It's Lucrezia's turn today. Scroll down and enjoy reading! Social media has been a great way for people to connect with others around the world. However, it has also become a source of distraction for many people. While some use social media responsibly to enhance their lives, many have become overly reliant on it. This has led to people being distracted during conversations or even losing track of their schedules, and this is one of the bad aspects about today's topic: social media. Did you know that around 62% of the world's population use social media? While this may seem obvious, it's actually an insane percentage considering that 74% of people in the world have access to safely managed drinking water, and the small numerical difference between these two is actually very relevant in daily life, so how much do we actually need social media? what are the
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!)
The solution for this problem will be in the next part of the article, coming out in May!
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