An understanding of programming language with Python

By reading this article you will be able to understand what is Python and what a programming language does in general.
Maybe you have heard that Python is a famous programming language used in several applications. And that is true, not all programming languages are similar and thus, their applications differ from each other. In the case of Python it can be used for:
- IoT(Internet of Things)
- AI(Artificial Intelligence)
- Backend(Web development)
- Data Science
- Among others
What is a programming language?
So, if we want to understand what happens within Python rules we have to know what a programming language is. Basically, a programming language is a formal language, that allows a programmer to write orders through some instructions and parameters. These instructions will handle types of data to make things work as we want.
Any modern programming language or turning completeness must allow you to handle the basic data types or primitives(included in the language) data types we need to implement any type of algorithm(set of instructions). Some of them are int(integers), str(strings), float(float numbers), etc. And some algorithm “tools” we would need are loops, conditionals, and logic operators.
Show me the python!
Alright, let’s dig into python right away. Anytime you create a new variable, function, data, or data structure it will be called an “object”. It sounds obvious, right? well, yes but there’s a reason behind that name, an object(no matter if it’s alive or not) has a characteristic and a behavior: persons, animals, a car, a printer, a door, anything that you can imagine has a characteristic, a state, and behavior. This mindset in programming is called OOP(Object-oriented Programming) and no, not all languages handle things this way or even more, not all programmers and projects work under this paradigm, why? well, it depends on the project you are working with. Most likely an e-commerce webpage could use OOP since it will handle a lot of categories and different kinds of articles we will create within. On the other hand, a simple webpage of content, let’s say your personal webpage to show your portfolio won’t need this kind of paradigm.
When we talk about an object we could refer to it as a value of a certain data type stored in memory.

In the last example, we can see the variables day_of_month, day_of_week, and students. Those are just references or labels we give to the values. In that way, we can set several variables or aliases to one single object. For example:

Aliasing
When we create an alias we are assigning one variable to another, at the end both variables refer to the same object.
Containers
As you saw in the last example with [“Peter”, “Andrew”, “Angela”, “Mary” ]. Some objects contain references to other objects, these objects are called “containers” and the following are examples of containers: lists, tuples, and dictionaries. Let’s learn more about them in the following bullet “Mutable and immutable objects”.
Mutable and immutable objects
When talking about an object’s value we can categorize them by mutable and immutable. A mutable object is an object whose value can change.
- Some of the mutable data types in Python are list, dictionary, set, byte array, and user-defined classes(or abstract data type).
- On the other hand, some of the immutable data types are int, float, decimal, bool, string, tuple, frozen sets, bytes, complex, and range.

Type
Even if it’s mutable or immutable every object has a data type. To get a data type of an object we can use the method or function type() it will receive as an argument de data type and as a result, it will return the data type the object belongs.
Immutable objects in memory
When we reference an object with a variable it will have a memory allocation. If we decide to dereference that object, it will still exist in memory, even if no variable is using it. Let’s see the following memory scheme example.

id
Anytime we create an object in Python. It will have a unique identification. Why? because it represents the address in memory. The only objects that will have a constant id will be the integers in the range of -5 and 256. To search which id belongs to an object we can use the method id().
Passing a variable to a function as an argument
To understand how a variable works as an argument in a function it will be determined simply by its mutable or immutable nature. If it’s an immutable value(for example an int) it will be passed as a value, on the other hand, if we pass a mutable argument it could be changed then since it is passed as a reference.
I hope with this overview you can get a better understanding of how the Python language works. Let’s keep learning!