What is Python? Detailed Description for Beginners

Starting to study something without having a basic understanding of the fundamentals is stupid. And the principle of "let's figure it out as we go" does not work here because "as we go" you simply will not go beyond simple home projects.

Learning programming "before it became mainstream" was much more difficult than it is now, for one simple reason: no one chewed and divided the information into important "you will never need it", there were no express training lessons and intensive courses where they write their pet project in 4 hours. Now we have a large array of so-called developers who successfully perform their tasks, but they know the match superficially.

That's why let's run through the foundation of such a simple but, as it turned out, mysterious Python language. Fasten your seat belts, gentlemen.

What is Python as a programming language?

In general, Python can be described in one sentence:
A high-level, interpreted, object-oriented, imperative, strongly typed general-purpose language that has dynamic typing.

Now let's go sequentially on each of the points.

High - level

Programming languages are divided into high-level and low-level. Low-level languages are languages close to machine code or its constructs (for example, bytecodes). Classics of such languages are C, Assembler, Forth.

High-level languages are developed accordingly for ease of use and speed of writing a program. They use certain abstractions — data structures, a set of auxiliary functions, and so on. These are languages such as Python, JS, PHP, Go,

Interpreted

Languages are divided into interpreted (Python, JS, PHP, R, Ruby) and compiled (C, C++, Pascal). In the first case, the program is executed by a special interpreter program, in the second, the program is first converted into executable files understandable to the computer.

Object-oriented

All languages are also divided into procedural, functional, and object-oriented, depending on which constructs the program is created with and how it is executed.

In object-oriented languages, the basis is classes and instances of classes, which are equivalent to a type and an object of this type. The execution of conditional tasks or just the work of the program is based on the interaction of various classes.

Although Python is an object-oriented language, it also supports procedural programming, which means that a program can be written without a single class.

Functional languages are based on a different computing system from the previous ones, called lambda calculus, which, nevertheless, is equivalent to a Turing machine, as proved by the corresponding theorem (thanks to my teacher for this paragraph).

Imperative

Programming languages can also be divided into imperative and declarative. In an imperative language, the programmer will specify a sequence of commands to execute (these are all programming languages that we consider "programming languages", sorry for the tautology).

Declarative languages, in turn, expect us to describe the result that we want to get during the execution of the query. A striking example of a declarative language is SQL (Structured Query Language) or structured query language. It is in it that we describe the specific result of the program execution and not the sequence of commands. Declarative languages are also called HTML, CSS, SVG, VRML, SQL, lex/VACC.

To understand the definitions of an imperative and declarative language, we will set a task: to build a house.
Imperative: Go to the store -> Buy materials -> Prepare the site -> Make construction —> Move in.

Declarative: I want a new house.

Strictly (strongly) typed

As for typing. In a strongly typed language, the interpreter, when executing commands, will not implicitly cast types, unlike weakly typed languages, in which typecasts can occur implicitly.

General-purpose

Languages are divided into general-purpose languages (Python, Java, Kotlin, C, Ruby) and specialized (for example, domain-oriented languages or DSL)

DSL (domain-oriented language) is a computer language specialized for a specific field of application (as opposed to a general-purpose language applicable to a wide range of fields and does not take into account the specifics of specific fields of knowledge). The construction of such a language and/or its data structure reflect the specifics of the tasks solved with its help. It is a key concept of language-oriented programming. Examples of such languages are Perl, SQL, HTML, Haskell, Verilog, AutoLISP

Dynamic typing

Dynamic typing assumes that during the execution of a command, a variable can contain objects of various types. That is, we declare a variable without explicitly specifying what type of data it will contain, and during the execution of the program, both text and a number can be in one variable, and maybe a Boolean value.

Static typing assumes that when setting a variable, the data type that it can contain is immediately indicated.

Distinctive features of the Python language

Introspection

In programming, this is the ability of a program to receive various information about objects while the program is running. Specifically, you can find out which class the object belongs to, what type of data you are working with at the moment (remember dynamic typing?) or a list of attributes and methods available for the specified object

Examples of useful introspection functions in Python:

  • dir();
  • type();
  • hasattr();
  • id();
  • isinstance().

Multiplatform

No, well Java too, yes. But Python does not lag behind, it goes, as they say, in a box with Linux and SQL Server, the Python interpreter can be easily installed on Windows, do not forget about macOS and iOS. Yes, it works everywhere, 8 times slower than Swift on iOS, but it works.

Built-in design patterns

Python has its own built-in design patterns, the best example for understanding is the Decorator and Iterator.

The decorator allows you to extend functionality without inheritance. To understand the Iterator pattern, you should simply study the mechanism of operation of iterators and language generators (I wrote about them here)

Extensive set of standard libraries

When using Core Python, you get a large set of useful standard libraries "in a box". An example is a library for working with SQLite databases, as well as JSON, math, re, random, CSV, HTML, and many others.

Language readability

Formatting text in Python as part of its syntax, and yes, these are the very indents (spaces, tabs, as you like) that allow you to increase the readability of the code.

Conclusion

Python is a beautiful, concise, and multifunctional language. It is used in completely incompatible fields of activity, is able to create projects alone, and not look at the possibilities of competitive languages.

A common problem encountered among amateur developers is superficiality in learning Python. The training materials that you (we) meet on the Internet are paraphrased hundreds of times and hide important, useful features and features of programming languages.

It is very important to fill in the blank spots in your knowledge not only at the beginning of your studies but also throughout your career, otherwise tomorrow the phrase "give way to the young" will become relevant for you, and you will find yourself overboard.

P.S.

The Python language is named after the comic group Monty Python and not after the snake.
The creator of the language Guido Van Rossum

PEP — Python Enhancement Proposals.

PEP-8 is a set of rules on how to write code.

Put on Heart if you liked it and you learned something new!

You can also follow ME to receive notifications about new interesting articles.

FAQ

I am a beginner, how should I learn Python?

Look into the following series:

Would you mentor me?

Of course I am ready to participate in the training. The big difficulty is that English is not my native language and it will be possible to communicate through a translator

Would you like to collaborate on our organization?

If you have interesting ideas, we will be happy to invite your writing from our organization. Write in private messages or in social networks below

If you have interesting projects and you need a backend developer, then you can contact me by mail or in discord for cooperation

Connect to me on

Discord: vadimkolobanov#5875

20