<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vadim Kolobanov</title>
    <description>The latest articles on DEV Community by Vadim Kolobanov (@vadimkolobanov).</description>
    <link>https://dev.to/vadimkolobanov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F733470%2Ff544160c-6e21-4566-9969-edd5c49795fe.jpg</url>
      <title>DEV Community: Vadim Kolobanov</title>
      <link>https://dev.to/vadimkolobanov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vadimkolobanov"/>
    <language>en</language>
    <item>
      <title>A Feature with an F-string that I Found out about by Accident</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Thu, 27 Oct 2022 10:34:41 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/a-feature-with-an-f-string-that-i-found-out-about-by-accident-2d95</link>
      <guid>https://dev.to/vadimkolobanov/a-feature-with-an-f-string-that-i-found-out-about-by-accident-2d95</guid>
      <description>&lt;h2&gt;
  
  
  From author
&lt;/h2&gt;

&lt;p&gt;You can find many interesting articles on my website, please visit it &lt;a href="https://happypython.ru/"&gt;Happy Python Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look, here is the usual f-string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text = 'JUPI'
print(f'{text}') 
JUPI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If I add to it&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;colon, &lt;/li&gt;
&lt;li&gt;placeholder char, &lt;/li&gt;
&lt;li&gt;and I will specify the required string length using the &amp;lt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(f'{text:-&amp;lt;15}') 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the rest of the line that is not occupied by the text will be filled with the selected character:&lt;/p&gt;

&lt;p&gt;JUPI-----------&lt;/p&gt;

&lt;p&gt;If you specify the length of the string via &amp;gt;, then you can fill in the line on the left side:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(f'{text:-&amp;gt;15}') 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-----------JUPI&lt;/p&gt;

&lt;p&gt;Write in the comments how to fill in the line on both sides so that it turns out &lt;/p&gt;

&lt;p&gt;-----JUPI------&lt;/p&gt;

</description>
    </item>
    <item>
      <title>5 handy PyCharm Plugins and 10 Hotkeys for Beginner</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Wed, 26 Oct 2022 06:02:03 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/5-handy-pycharm-plugins-and-10-hotkeys-for-beginner-4gpd</link>
      <guid>https://dev.to/vadimkolobanov/5-handy-pycharm-plugins-and-10-hotkeys-for-beginner-4gpd</guid>
      <description>&lt;h2&gt;
  
  
  From author
&lt;/h2&gt;

&lt;p&gt;You can find many interesting articles on my website, please visit it &lt;a href="https://happypython.ru/"&gt;Happy Python Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Automatic translation in the browser will help you to study everything conveniently. &lt;/p&gt;

&lt;p&gt;If the material is useful, I will try to translate all my articles for you&lt;/p&gt;

&lt;p&gt;I think all developers, after choosing a programming language for themselves, thought about the question: "Where to write code?" I, as a developer in the Python programming language, turned to the Internet, where many answers were found.&lt;/p&gt;

&lt;p&gt;For different languages — there are correspondingly different solutions. In fact, the development environment is just a programmer's "comfort zone" and it will not suit everyone. This applies not only to Python, but also to other languages.&lt;/p&gt;

&lt;p&gt;After reading a few articles, I settled on the PyCharm environment for Python. It was developed by JetBrains, has a paid and free version, as well as many features that really attract with their ease of use.&lt;br&gt;
Let's look at some of them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fY4-zfk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ppi377naqo28u8xqloe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fY4-zfk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ppi377naqo28u8xqloe.png" alt="Plugins" width="880" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5 frequently used plugins of the PyCharm development environment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The top plugin for developers of all levels is &lt;a href="https://plugins.jetbrains.com/plugin/11945-python-smart-execute"&gt;Python Smart Execute&lt;/a&gt;. Do you want to test the operation of a separate piece of your code? Plug-in to help, install it, highlight the code and click Smart execute. See how a piece of code worked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Since I am not familiar with English and other languages, sometimes I have to translate comments in the code of other developers. Jumping into the browser every time to translate text is not a good allocation of working time, especially when you could write a few lines of good code during this time.&lt;br&gt;
I had to look for a way out of the situation by turning to the Internet again. It turned out there is a plugin called &lt;a href="https://plugins.jetbrains.com/plugin/8579-translation"&gt;Translation&lt;/a&gt;, which allows you to use the translator immediately from the code. A very cool thing, you select the text and click on the translator icon in the upper right corner and understand what your colleague is talking about.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All employers are interested in developers with the ability to write beautiful code. This is a fact. Sometimes it is impossible to keep track of the whole code, therefore your remuneration for work is reduced by several kilograms of gingerbread. What to do? Use the &lt;a href="https://plugins.jetbrains.com/plugin/11084-pylint"&gt;PyLint plugin&lt;/a&gt; — indicates to the developer where he left a piece of bad code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do novice developers often get confused about the correct naming of classes, functions and variables? To use the &lt;a href="https://plugins.jetbrains.com/plugin/7973-sonarlint"&gt;SonarLint plugin&lt;/a&gt; — checks the naming correctness and detects errors. Top for beginners.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Too lazy to type the code manually? Use the &lt;a href="https://plugins.jetbrains.com/plugin/12798-tabnine-ai-code-completion-js-java-python-ts-rust-go-php--more"&gt;Tabnine&lt;/a&gt; plugin, which with the help of artificial intelligence will tell you what to write.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  10 popular hotkeys, for PyCharm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Ctrl + D — Duplicate a line when you write similar lines, now there is no need to type them first or select and copy.&lt;/li&gt;
&lt;li&gt;Alt + Enter — Bring the code to the rules of PEP-8. Very convenient.&lt;/li&gt;
&lt;li&gt;Ctrl + R — Decided to rename the class? Will change the name in the entire project.&lt;/li&gt;
&lt;li&gt;Ctrl + Shift + N — Search for a class or method throughout the project.&lt;/li&gt;
&lt;li&gt;Ctrl + Alt + M — We wrote the code, now we wanted to wrap it in a function, here's the combination.&lt;/li&gt;
&lt;li&gt;Ctrl + Alt + S — Go to settings.&lt;/li&gt;
&lt;li&gt;Ctrl + Y — Delete the line.&lt;/li&gt;
&lt;li&gt;Ctrl + B — Move to this class.&lt;/li&gt;
&lt;li&gt;Ctrl + F12 — Shows the data structure of the file.&lt;/li&gt;
&lt;li&gt;Alt + F7 — See where this class, method or function is used.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article describes only the functions and plugins that I personally use frequently. I have been writing for about 3 years, I got to the middle developer in Python. I started using these tools in the middle of 2020, which allowed me to rise from the junior position. Use it! I am waiting for you at the position of senior python developer&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Basic data types in Python 3. Examples of working with collections for beginners</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Tue, 25 Oct 2022 07:33:48 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/basic-data-types-in-python-3-examples-of-working-with-collections-for-beginners-4l4b</link>
      <guid>https://dev.to/vadimkolobanov/basic-data-types-in-python-3-examples-of-working-with-collections-for-beginners-4l4b</guid>
      <description>&lt;h2&gt;
  
  
  From author
&lt;/h2&gt;

&lt;p&gt;You can find many interesting articles on my website, please visit it &lt;a href="https://happypython.ru/"&gt;Happy Python Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Automatic translation in the browser will help you to study everything conveniently. &lt;/p&gt;

&lt;p&gt;If the material is useful, I will try to translate all my articles for you&lt;/p&gt;

&lt;p&gt;In this article, we will analyze how Python works with variables and what data types can be used in this language.&lt;br&gt;
If we approach the question of Python typing, we can say that it refers to a language with implicitly strong dynamic typing.&lt;br&gt;
Implicit typing is understood so that when declaring a variable, the programmer does not need to specify its type. That is, you do not need to write "int a = 1", as it is written, for example, in C++ and many other languages.&lt;/p&gt;

&lt;p&gt;In Pytnon, data types can be divided into built-in and non-built-in, which are used when importing modules.&lt;/p&gt;
&lt;h2&gt;
  
  
  Data Types in Python
&lt;/h2&gt;

&lt;p&gt;The main built - in types include…&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;None (undefined variable value)&lt;/li&gt;
&lt;li&gt;Boolean Variables (Boolean Type)&lt;/li&gt;
&lt;li&gt;Numbers (Numeric Type)&lt;/li&gt;
&lt;li&gt;int – integer&lt;/li&gt;
&lt;li&gt;float – floating point number&lt;/li&gt;
&lt;li&gt;complex – complex number&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Sequence Type
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;list&lt;/li&gt;
&lt;li&gt;tuple&lt;/li&gt;
&lt;li&gt;range &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Strings (Text Sequence Type )
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;str&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Binary Lists (Binary Sequence Types)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;bytes – bytes&lt;/li&gt;
&lt;li&gt;bytearray – arrays of memoryview bytes – special objects for accessing the internal data of an object via protocol buffer&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Sets (Set Types)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;set&lt;/li&gt;
&lt;li&gt;frozenset – immutable set&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Dictionaries (Mapping Types)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;dict - dictionary&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Initializing variables and working with them
&lt;/h2&gt;

&lt;p&gt;In order to immediately declare and initialize a variable, it is necessary to write its name, then put an equal sign and the value with which this variable will be created. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;value = 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The integer value 10 within the Python language is essentially an object. An object, in this case, is an abstraction for representing data, data is numbers, lists, strings, etc. At the same time, data should be understood as both the objects themselves and the relationships between them. Each object has three attributes – an identifier, a value, and a type. An identifier is a unique feature of an object that allows you to distinguish objects from each other, and a value is directly information stored in memory, which is controlled by an interpreter and a type – a concept that determines what exactly a value is.&lt;/p&gt;

&lt;p&gt;To determine the identifier, there is a built-in id function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;value = 10
id(value)
140654768777808
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need to get a value, use the print function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;value = 10
print(value)
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it remains to find the type using the "type" function:&lt;/p&gt;

&lt;p&gt;There are mutable and immutable types in Python:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Immutable types include: integers (int), floating point numbers (float), complex numbers (complex), boolean variables (bool), tuples (tuple), strings (str) and immutable sets (frozen set).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mutable types include: lists , sets , dictionaries (dict).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic data types in Python with examples:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Numbers
&lt;/h3&gt;

&lt;p&gt;Integers, floating point numbers, and complex numbers belong to a group of numbers. In Python, they are represented by the int, float and complex classes.&lt;/p&gt;

&lt;p&gt;Integers can be of any length, they are limited only by available memory.&lt;/p&gt;

&lt;p&gt;Floating point numbers have limited precision. Visually, the difference between an integer and a floating—point number can be seen in the console by the presence of a dot: 1 is an integer, 1.0 is a floating-point number.&lt;/p&gt;

&lt;p&gt;Complex numbers are written in the form x+yj, where x is the real part of the number and y is the imaginary part. Here are some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
a = 12345678901234567890
a
12345678901234567890
type(a)

b = 0.12345678901234567890
b
0.12345678901234568
type(b)

c = 1 + 2j
c
(1+2j)
type(c)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the value of variable b has been truncated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strings
&lt;/h3&gt;

&lt;p&gt;A string is a sequence of characters. We can use single or double quotes to create a string. Multiline strings can be indicated with triple quotes, ''' or """:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;s = "Simple string"
s = '''multiline string'''
s = """multiline string"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is worth noting that strings in Python belong to the category of immutable sequences, that is, all functions and methods can only create a new string.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lists
&lt;/h3&gt;

&lt;p&gt;A list is an ordered sequence of elements. It is very flexible and is one of the most used types in Python. The list items do not have to be of the same type.&lt;/p&gt;

&lt;p&gt;Declaring a list is pretty simple. The comma-separated list items are placed inside the square brackets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; a = [1, 2.2, 'python']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use the [] operator to extract an element (such an operation is called "index access") or a range of elements (such an operation is called "slice extraction") from a list. In Python, indexing starts from scratch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = [5,10,15,20,25,30,35,40]
print("a[2] =", a[2])
a[2] = 15

print("a[0:3] =", a[0:3])
a[0:3] = [5, 10, 15]

print("a[5:] =", a[5:])
a[5:] = [30, 35, 40]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists are a mutable type, i.e. the values of its elements can be changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = [1,2,3]
a[2] = 4
a
[1, 2, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tuples
&lt;/h3&gt;

&lt;p&gt;Just like a list, a tuple is an ordered sequence of elements. The whole difference is that tuples are immutable.&lt;/p&gt;

&lt;p&gt;Tuples are used to protect data from overwriting and usually work faster than lists, because they cannot be changed.&lt;/p&gt;

&lt;p&gt;To create a tuple, you need to put comma-separated elements inside the parentheses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;t = (5,'program', 1+3j)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use the slice extraction operator [] to extract elements, but we cannot change their values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;t = (5,'program', 1+3j)
print("t[1] =", t[1])
t[1] = program

print("t[0:3] =", t[0:3])
t[0:3] = (5, ' program', (1+3j))
# Leads to an error because
# tuples are immutable
t[0] = 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sets
&lt;/h3&gt;

&lt;p&gt;The set is an unordered, unique sequence. A set is declared using comma-separated elements inside curly brackets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {5,2,3,1,4}
# output of a set variable
print("a =", a)
a = {1, 2, 3, 4, 5}
# data type of variable a
print(type(a))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can perform operations such as union and intersection on sets. Since the elements in the set must be unique, they automatically remove duplicates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {1,2,2,3,3,3}
a
{1, 2, 3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the set is an unordered sequence, the slice extraction operator does not work here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {1,2,3}
a[1]
Traceback (most recent call last):
  File "", line 1, in  
TypeError: 'set' object does not support indexing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dictionaries
&lt;/h3&gt;

&lt;p&gt;Dictionaries are unordered sets of key-value pairs.&lt;/p&gt;

&lt;p&gt;They are used when you need to map a value to each of the keys and be able to quickly access the value by knowing the key. In other languages, dictionaries are usually called map, hash, or object. Dictionaries are optimized for data extraction. To extract the value, you need to know the key.&lt;/p&gt;

&lt;p&gt;The dictionary is declared by pairs of elements in the form of a key:value enclosed in curly brackets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d = {1:'value', 'key':2}
type(d)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value can be of any type, but the key is only immutable.&lt;/p&gt;

&lt;p&gt;We use the key to get the corresponding value. But not the other way around:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d = {1:'value', 'key':2}
print("d[1] =", d[1])
d[1] = value
print("d['key'] =", d['key'])
d['key'] = 2

# Causes an error
printing("d[2] =", d[2]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The python programming language gives a huge advantage over other languages. No wonder it is one of the most popular and multi-platform, can be used in any direction, and in some cases is indispensable.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Hi all. What's new?</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Sat, 26 Mar 2022 08:20:40 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/hi-all-whats-new-1b9o</link>
      <guid>https://dev.to/vadimkolobanov/hi-all-whats-new-1b9o</guid>
      <description></description>
    </item>
    <item>
      <title>What is Python? Detailed Description for Beginners</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Fri, 07 Jan 2022 18:50:44 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/what-is-python-detailed-description-for-beginners-20de</link>
      <guid>https://dev.to/vadimkolobanov/what-is-python-detailed-description-for-beginners-20de</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@douglasamarelo?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Douglas Lopes&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/python?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Python as a programming language?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;In general, Python can be described in one sentence:&lt;br&gt;
A high-level, interpreted, object-oriented, imperative, strongly typed general-purpose language that has dynamic typing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now let's go sequentially on each of the points.&lt;/p&gt;

&lt;h3&gt;
  
  
  High - level
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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,&lt;/p&gt;

&lt;h3&gt;
  
  
  Interpreted
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;
  
  
  Object-oriented
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

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

&lt;p&gt;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).&lt;/p&gt;

&lt;h3&gt;
  
  
  Imperative
&lt;/h3&gt;

&lt;p&gt;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).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To understand the definitions of an imperative and declarative language, we will set a task: to build a house.&lt;br&gt;
Imperative: Go to the store -&amp;gt; Buy materials -&amp;gt; Prepare the site -&amp;gt; Make construction —&amp;gt; Move in.&lt;/p&gt;

&lt;p&gt;Declarative: I want a new house.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strictly (strongly) typed
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;
  
  
  General-purpose
&lt;/h3&gt;

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

&lt;p&gt;&lt;em&gt;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&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic typing
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Static typing assumes that when setting a variable, the data type that it can contain is immediately indicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Distinctive features of the Python language
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introspection
&lt;/h3&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;p&gt;Examples of useful introspection functions in Python:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dir();&lt;/li&gt;
&lt;li&gt;type();&lt;/li&gt;
&lt;li&gt;hasattr();&lt;/li&gt;
&lt;li&gt;id();&lt;/li&gt;
&lt;li&gt;isinstance().&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Multiplatform
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;
  
  
  Built-in design patterns
&lt;/h3&gt;

&lt;p&gt;Python has its own built-in design patterns, the best example for understanding is the Decorator and Iterator.&lt;/p&gt;

&lt;p&gt;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 (&lt;a href="https://dev.to/abstract/5-python-tricks-in-one-line-beginner-vs-professional-5b0j"&gt;I wrote about them here&lt;/a&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Extensive set of standard libraries
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;
  
  
  Language readability
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  P.S.
&lt;/h2&gt;

&lt;p&gt;The Python language is named after the comic group Monty Python and not after the snake.&lt;br&gt;
The creator of the language Guido Van Rossum&lt;/p&gt;

&lt;p&gt;PEP — Python Enhancement Proposals.&lt;/p&gt;

&lt;p&gt;PEP-8 is a set of rules on how to write code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;
&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Would you mentor me?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Would you like to collaborate on our organization?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you have interesting projects and you need a backend developer, then you can contact me by mail or in discord for cooperation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Face....oh...Meta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Discord: vadimkolobanov#5875&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Poetry vs pip: Or How to Forget Forever "requirements.txt" Cheat Sheet for Beginners</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Mon, 06 Dec 2021 13:43:45 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/poetry-vs-pip-or-how-to-forget-forever-requirementstxt-cheat-sheet-for-beginners-33h1</link>
      <guid>https://dev.to/vadimkolobanov/poetry-vs-pip-or-how-to-forget-forever-requirementstxt-cheat-sheet-for-beginners-33h1</guid>
      <description>&lt;p&gt;You can find many interesting articles on my website, please visit it &lt;a href="https://happypython.ru/"&gt;Happy Python Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Automatic translation in the browser will help you to study everything conveniently.&lt;/p&gt;

&lt;p&gt;If the material is useful, I will try to translate all my articles for you&lt;/p&gt;

&lt;p&gt;Poetry is a dependency management tool in Python projects (analogous to the built-in pip). &lt;/p&gt;

&lt;p&gt;It will be vital for beginners in Python to get acquainted with this tool, as it is a very simple and easy-to-use tool, the use of which can simplify the management and development of the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can install poetry on windows either using pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install poetry
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or with PowerShell (Windows)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pip stores dependency data in a file requirements.txt (or something else, but more often it is), poetry stores information in the pyproject.toml file, however, in the case of pip, only a list of dependencies and versions is stored in its file, and all basic information about the project is stored in .toml. It is very convenient, you can always find all the information in one place&lt;/p&gt;

&lt;p&gt;To install dependencies in pip, you need to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;poetry makes it easier and more beautiful&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;installation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;poetry install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;poetry update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Viewing dependencies in pip is done like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip freeze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will only be able to see the current versions of the libraries and will not get the structure of all packages with their dependencies. In poetry, in poetry.the lock file, you can view information about all installed packages, the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;poetry show --tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will show the tree structure of packages with their personal dependencies.&lt;/p&gt;

&lt;p&gt;Also, launching a project in pip (in the case of a virtual environment) creates inconveniences, since the first thing you need to do is go into this very environment.&lt;/p&gt;

&lt;p&gt;There is no need to activate the virtual environment in poetry, just go to the project folder and start using the commands. Poetry will find the right environment by itself.&lt;br&gt;
You can also change the python version in poetry without having to change the old virtual environment.&lt;/p&gt;

&lt;p&gt;This is only a small part of the benefits.&lt;br&gt;
Now a little bit about the .toml file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[tool.poetry]
name = "new_proj"
version = "0.1.0"
description = "DEVoneLove"
authors = ["Vadim Kolobanov &amp;lt;titanyforgame@gmail.com&amp;gt;"]

[tool.poetry.dependencies]
python = "^3.10"
pygame = "^2.1.0"
icecream = "^2.1.1"
requests = "^2.26.0"
psycopg2 = { version = "^2.7", optional = true }
pymysql = { version = "1.0.2", optional = true }

[tool.poetry.dev-dependencies]
Pympler = "^0.9"

[tool.poetry.urls]
"My GitHub" = "https://github.com/vadimkolobanov"

[tool.poetry.scripts]
run-main = "new_proj.main:main_def"

[build-system]
requires = ["poetry-core&amp;gt;=1.0.0"]
build-backend = "poetry.core.masonry.api"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;[tool.poetry] - contains basic information about the project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;[tool.poetry.dependencies] - contains a description of all project dependencies. A link to Github is specified.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;[tool.poetry.scripts] - contains scripts that need to be run when installing dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;[tool.poetry.extras] - dependency groups for a separate installation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;[tool.poetry.urls] - Along with the main URLs, you can specify your own links&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;The study and effective use of new programming language features distinguishes a real programmer from a populist who talks about his skills more than he knows how.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(c) Vadim Kolobanov 2021 AD&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h3&gt;
  
  
  FAQ
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Facebook&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;br&gt;
&lt;p&gt;To beat depression, try to just quit &lt;a href="https://twitter.com/hashtag/programming?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#programming&lt;/a&gt; 🤪&lt;/p&gt;— Vadim Kolobanov (@decodesperato) &amp;lt;a &lt;br&gt;
&lt;/blockquote&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Detailed Python: or How to Cross the Border of Knowledge</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Mon, 29 Nov 2021 09:57:56 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/detailed-python-or-how-to-cross-the-border-of-knowledge-29j8</link>
      <guid>https://dev.to/vadimkolobanov/detailed-python-or-how-to-cross-the-border-of-knowledge-29j8</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@emilep?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Emile Perron&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/python?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you want your code to look high-quality and concise and speak about you as an experienced developer? Then let's dive a little deeper into the basic knowledge and see how much you can simplify your code, how to make it readable and not lose the desire to return to your work again. Welcome to detailed Python. It's time to get better!&lt;/p&gt;

&lt;p&gt;If you started learning Python, watched a dozen training videos, took several free courses, intensive courses and meetups, and are trying to write your first project, then this article will certainly help you. A superficial analysis of Russian-language Python training materials on the Internet suggested that a novice Python developer is rarely shown the beauty and effectiveness of this language. Basic (often non-professional) training involves familiarity with the simplest mechanics, which are often found in other languages. The road will be mastered by the walking one, which means let's strive for more.&lt;/p&gt;

&lt;h1&gt;
  
  
  In this article you will see:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;List comprehensions (List Generator)&lt;/li&gt;
&lt;li&gt;Unpacking items from a list&lt;/li&gt;
&lt;li&gt;Slicing (Slices or Slices)&lt;/li&gt;
&lt;li&gt;Some nice Python language tricks&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  List comprehensions (List generator)
&lt;/h1&gt;

&lt;p&gt;In most cases, list generators are used to create a list from a set of values - so as not to resort to more complex constructions via for and append.&lt;/p&gt;

&lt;p&gt;Speaking in detail, the list generator can create a collection of values in just one line. Let's see an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;81&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example, we took a sequence of numbers from 0 to 9 (our range) and squared each iteration of the loop, after which we wrote the result to the end of the empty list declared above.&lt;/p&gt;

&lt;p&gt;So, the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;81&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great. And it is difficult to criticize this method because it works, is readable, not cumbersome, right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example using a list generator:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;81&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From four lines to one. Is it beautiful, readable, concise?&lt;/p&gt;

&lt;p&gt;Now learn more about the syntax of the generator. In general, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;iterator&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;iterable&lt;/span&gt; &lt;span class="nb"&gt;object&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, the generator can also contain a condition under which the iterated elements will fall into the list. I'll show you an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only even numbers were included in the list (if read by condition, these are those that are divisible by 2 without remainder)&lt;/p&gt;

&lt;p&gt;Here the efficiency of the generator is even more pronounced. You combine both a loop and a conditional operator in one expression and get an ordered, mutable list at the output.&lt;/p&gt;

&lt;p&gt;Now, raise the level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;some_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;some_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;6.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;6.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;7.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use an expression as a function argument. This is convenient, and your code will leave a pleasant impression about you.&lt;/p&gt;

&lt;p&gt;It is worth mentioning that the generator exists not only for lists, but also for dict and set and is called Dict comprehensions and Set comprehensions, respectively. Their basic syntax is similar. I will show the differences with an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;dict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pay attention to the type of brackets in the list and in these two examples.&lt;/p&gt;

&lt;h1&gt;
  
  
  Unpacking items from a list
&lt;/h1&gt;

&lt;p&gt;If you need to get a certain element from the collection, then the first and obvious method is to get it by index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;when&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method can be used effectively if your collection is immutable, and lst[1] will always contain the value you need. The disadvantage of the approach is the so-called "magic numbers". Imagine that you are reading someone else's code, in which the developer gets the value, as in the example. You won't have any questions: "What is lst[1]? Why 1 and not 2 and not 20?" That's why they call such numbers in parentheses "magic numbers". Appeared out of nowhere, denote something inside. You should learn how to use unpacking.&lt;/p&gt;

&lt;p&gt;Python allows you to assign collection values to individual variables. This is effective if the collection is small. Read more in the example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the same time, it's worth looking at how to assign multiple values to multiple variables at once, and how to replace variables beautifully.&lt;/p&gt;

&lt;h1&gt;
  
  
  Multiple assignment
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This expression is equivalent to :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But you took 3 lines instead of one. Is it normal if your project will be 50 lines, and if 300 or 800?&lt;/p&gt;

&lt;h1&gt;
  
  
  Replacing variables.
&lt;/h1&gt;

&lt;p&gt;In order to swap variables, you can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;
&lt;span class="n"&gt;_tmp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; 
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; 
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_tmp&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But there is a way to make this record shorter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of the principles of the Python language states:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Readability counts&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So let's be real "pythonists" in our works.&lt;/p&gt;

&lt;h1&gt;
  
  
  Slicing
&lt;/h1&gt;

&lt;p&gt;Speaking of large collections. What if we need multiple values from a collection? And what if they are needed from the middle or through one? Python provides such a mechanism, which is called Slicing or Slices. The syntax is quite simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sequence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;start&lt;/strong&gt; = index of the element from which the slice starts;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;stop&lt;/strong&gt; = index of the element that ends the slice;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;step&lt;/strong&gt; = slice step.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We took every second item in the list from between 1 and 6 indexes. In your work, you will often resort to the help of slices, do not underestimate them.&lt;/p&gt;

&lt;p&gt;Slices can be written easier. If the beginning or end of the slice is equivalent to the beginning and end of the list, they can be omitted. It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we take a slice from 0 to 2 of the index of the element with a step of 1. We didn't specify the beginning or the step, but only the end of the slice. Note that 3 is the index of the final element, but it does not fall into the final list, so the slice will be from 0 to 2 of the index.&lt;/p&gt;

&lt;p&gt;Now an example indicating the start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The slice started with index 3, but in this situation the element with index 3 got into the slice. A similar principle works in range. Just remember that. This way you will eliminate a number of errors in your code.&lt;/p&gt;

&lt;h1&gt;
  
  
  Some nice Python language tricks
&lt;/h1&gt;

&lt;p&gt;Many people believe that it was fashionable to monitor memory in the era of assembly language programming. Many, but not all. I'll give you a clear example of why sometimes it's worth thinking about which function to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;range_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;range_list&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="mi"&gt;48&lt;/span&gt; &lt;span class="c1"&gt;# bytes
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imagine that a sequence of numbers from 0 to 9999 takes up only 48 bytes.&lt;/p&gt;

&lt;p&gt;And here is an example with the same sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;real_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;real_list&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="mi"&gt;87616&lt;/span&gt; &lt;span class="c1"&gt;# bytes
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two identical sequences from 0 to 9999. They occupy memory with a difference of almost 2000 times. And if the program contains 100 such lists?&lt;/p&gt;

&lt;p&gt;The fact is that range only pretends to be a list, behaves like a list, but in fact, the range function returns a class and, of course, loads less memory.&lt;/p&gt;

&lt;p&gt;And finally, a small focus on the number of repetitions of the value in the collection (a favorite task in various tutorials and courses):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'abracadabra'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use a list instead of a string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;
&lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The argument in most_common specifies the number of repeatable elements that need to be counted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'abracadabra'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is worth noting that for the mechanisms described in the article to work correctly, it is necessary to have a full understanding of lists, dictionaries, sets, and tuples. These types of data are very insidious and have important differences that are worth paying attention to.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Deeper immersion in the technology being studied always brings its own result. After reading this material, you will get the opportunity to distinguish the code of a beginner (or lazy) from the code of a developer who loves his work, immerses himself in it, tries to do not only for himself but also for others. You will want to establish contact with such people, make a joint project or invite them to work. Writing code is like drawing: all paints are the same color, but some get a house with a triangular roof, while others have magnificent landscapes. The question is effort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tproger.ru/articles/podrobnyj-python-ili-kak-perestupit-granicu-znanij/"&gt;You can read the original article in Russian here&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h3&gt;
  
  
  FAQ
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Facebook&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;br&gt;
&lt;p&gt;To beat depression, try to just quit &lt;a href="https://twitter.com/hashtag/programming?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#programming&lt;/a&gt; 🤪&lt;/p&gt;— Vadim Kolobanov (@decodesperato) &amp;lt;a &lt;br&gt;
&lt;/blockquote&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What's New at Python 3.10 And Why You Should Know That ?</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Mon, 22 Nov 2021 10:38:59 +0000</pubDate>
      <link>https://dev.to/vadimkolobanov/whats-new-at-python-310-and-why-should-you-know-that--1jko</link>
      <guid>https://dev.to/vadimkolobanov/whats-new-at-python-310-and-why-should-you-know-that--1jko</guid>
      <description>&lt;p&gt;Hi, have you already learned Python 3.10? And what if you meet a project written on this version?  How fast can you figure out this code? Most people know that Python 3.10 has been released, but some beginner developers do not even pay attention to the features of the new version, because they are now working on 3.8, for example, and 3.10 is unnecessary for them. Soon most of the code will be written on version 3.10 and without knowing the specifics, you simply will not be able to read someone else's code correctly. Let's get acquainted with some innovations.&lt;/p&gt;

&lt;h1&gt;
  
  
  Improvements in type checking
&lt;/h1&gt;

&lt;p&gt;If you use type checking, you will be happy to hear that Python 3.10 includes many improvements in type checking, among them the type union operator, whose syntax is now cleaner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="c1"&gt;# Function that accepts either `int` or `float`
# Old:
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Union&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Union&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;

&lt;span class="c1"&gt;# New:
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Population Count (popcount)
&lt;/h1&gt;

&lt;p&gt;Starting with Python 3.10, to count the number of bits in the binary representation of an integer, you can call int.bit_count().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;bin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# '0b101010'
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bit_count&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# 3
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Performance improvements
&lt;/h1&gt;

&lt;p&gt;As with all recent Python releases, performance improvements will come with Python 3.10. The first is an optimization of the constructors str(), bytes(), and bytearray(), which should become about 30% faster (fragment adapted from the example in the Python bug tracker):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;pyperf&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;compare&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="s"&gt;"str()"&lt;/span&gt;
&lt;span class="n"&gt;Mean&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;81.9&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;60.0&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;1.9&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.36&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="n"&gt;faster&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;pyperf&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;compare&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="s"&gt;"bytes()"&lt;/span&gt;
&lt;span class="n"&gt;Mean&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;85.1&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;2.2&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;60.2&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;2.3&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.41&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="n"&gt;faster&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;pyperf&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;compare&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="s"&gt;"bytearray()"&lt;/span&gt;
&lt;span class="n"&gt;Mean&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;93.5&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;73.1&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="o"&gt;+-&lt;/span&gt; &lt;span class="mf"&gt;1.8&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.28&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="n"&gt;faster&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Better error messages
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;SyntaxErrors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, they added more accurate information in the syntax error message&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'{'&lt;/span&gt; &lt;span class="n"&gt;was&lt;/span&gt; &lt;span class="n"&gt;never&lt;/span&gt; &lt;span class="n"&gt;closed&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;invalid&lt;/span&gt; &lt;span class="n"&gt;syntax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;Perhaps&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;forgot&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;comma&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;did&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;forget&lt;/span&gt; &lt;span class="n"&gt;parentheses&lt;/span&gt; &lt;span class="n"&gt;around&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;comprehension&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;':'&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="s"&gt;'except'&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s"&gt;'finally'&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cannot&lt;/span&gt; &lt;span class="n"&gt;assign&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;Maybe&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;meant&lt;/span&gt; &lt;span class="s"&gt;'=='&lt;/span&gt; &lt;span class="n"&gt;instead&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="s"&gt;'='&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cannot&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="n"&gt;starred&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;IndentationError&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now this exception has more context as to which block was expecting an indent, and where the operator is located.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="nb"&gt;IndentationError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;indented&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="s"&gt;'if'&lt;/span&gt; &lt;span class="n"&gt;statement&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;AttributeError&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now it will prompt suggestions of similar attribute names in the object&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;collections&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;namedtoplo&lt;/span&gt;

&lt;span class="nb"&gt;AttributeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="s"&gt;'collections'&lt;/span&gt; &lt;span class="n"&gt;has&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s"&gt;'namedtoplo'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;Did&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;namedtuple&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NameError&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;it will also work by offering you a similar name from your code as AttributeError&lt;/p&gt;

&lt;h1&gt;
  
  
  Structural Pattern Matching(Match-Case)
&lt;/h1&gt;

&lt;p&gt;Before version 3.10, we had to use the if ... elif operator. Python version 3.10 introduced the match-case operator, which has more features than a simple selection operator. Its syntax is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
   &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
       &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'python'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# do something with py
&lt;/span&gt;       &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'c++'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# do something with cpp
&lt;/span&gt;       &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# default
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In fact, this is not all his opportunity. Let's look at some simple examples with the new operator&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structural patterns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, you need to check whether the analyzed object is a sequence (list or set):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
   &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What to do if we don't know the length of the incoming list, but only the first two elements are known. The match operator allows you to select the remaining elements of the sequence in a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="n"&gt;some_seq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;others&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="c1"&gt;# The first two elements are known
&lt;/span&gt;       &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Yes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;others&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
       &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If, however, the length of the sequence is known, and some elements may change, then they can also be set as variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="n"&gt;some_seq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;two&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;three&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
       &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Yes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;two&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;three&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another unexpected feature of structural templates is that you can check their values. For example, so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;other&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;other&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;other&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dictionaries as structural patterns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dictionaries can also serve as structural patterns. Now you can compare dictionaries by keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="n"&gt;some_dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"move"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"distance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;km&lt;/span&gt;&lt;span class="p"&gt;}:&lt;/span&gt;
       &lt;span class="n"&gt;move&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;km&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"stop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;}:&lt;/span&gt;
       &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using OR in a match-case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If some cases are handled in a similar way, then we can combine them as a logical expression using the OR (|) operation. Moreover, the OR operation can be used with literals, sequences, and dictionaries. Below is the Python code where the template with OR is used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
       &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
       &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sequence"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;A complete list of all changes is described in the Python documentation on the website &lt;a href="https://docs.python.org/3/whatsnew/3.10.html"&gt;Docs Python&lt;/a&gt;&lt;br&gt;
We looked at the most interesting and understandable changes for beginners. It should be understood that the Python 3.10 version is not stable yet and I would not recommend using it as the main interpreter for projects temporarily. You can install it for tests or training.&lt;/p&gt;

&lt;p&gt;Why is it useful for all Python developers to know these innovations? Soon we will all be faced with a new style of writing code, new operators, features, and syntactic changes from Python 3.10. The best will be the one who will be able to understand the new code before everyone else, having a lot of practice on previous versions.&lt;/p&gt;




&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h3&gt;
  
  
  FAQ
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Facebook&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;br&gt;
&lt;p&gt;To beat depression, try to just quit &lt;a href="https://twitter.com/hashtag/programming?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#programming&lt;/a&gt; 🤪&lt;/p&gt;— Vadim Kolobanov (@decodesperato) &lt;a href="https://twitter.com/decodesperato/status/1462680297691041795?ref_src=twsrc%5Etfw"&gt;November 22, 2021&lt;/a&gt;&lt;br&gt;
&lt;/blockquote&gt; 

</description>
      <category>python</category>
      <category>todayisearched</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>6 Elegant Tricks in Python for Beginners</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Sun, 21 Nov 2021 05:33:37 +0000</pubDate>
      <link>https://dev.to/abstract/a-few-useful-tricks-in-python-for-beginners-1bfa</link>
      <guid>https://dev.to/abstract/a-few-useful-tricks-in-python-for-beginners-1bfa</guid>
      <description>&lt;p&gt;Hello everyone! Let's see together what elegant mechanics professional Python developers use in their code&lt;/p&gt;

&lt;p&gt;I very often see such examples in some public Git repositories of experienced programmers.&lt;br&gt;
Let's get started&lt;/p&gt;
&lt;h1&gt;
  
  
  Sorting data by multiple keys
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;peoples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Janet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Ed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Sara'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Jane'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;peoples&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#Output
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Ed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Jane'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Janet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Sara'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'age'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;at the output, we get alphabetical sorting, and if the values match, the sorting takes place by the second key. This will not have an effect if there are no duplicate values in your data.&lt;/p&gt;
&lt;h1&gt;
  
  
  List comprehensions (List Generator)
&lt;/h1&gt;

&lt;p&gt;I have already shown an understanding of the list in my previous articles, here I will just show you a few possible uses&lt;/p&gt;

&lt;p&gt;Basic syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ expression for item in list if conditions ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A very simple example to fill in a list is a sequence of numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;mylist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mylist&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And since you can use an expression, you can also do some math.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;squares&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;squares&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;81&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can call a function as an expression&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;some_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;some_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;6.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;6.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;7.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, you can use "if" to filter the list. In this case, we only keep the values that are divisible by 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Control of memory in use by objects
&lt;/h1&gt;

&lt;p&gt;I have also already mentioned sys.getsizeof() in the articles, but here I want to show you an interesting example that will show all the usefulness of memory control&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;mylist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mylist&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just 48 bytes? Seriously? The list is from 0 to 9999?&lt;br&gt;
Yes, guys and why is this happening, I'll tell you now&lt;/p&gt;

&lt;p&gt;The fact is that range only pretends to be a list, behaves like a list, but in fact, the range function returns a class and it certainly loads less memory.&lt;/p&gt;

&lt;p&gt;For comparison, let's create a real list with the same range&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;myreallist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myreallist&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="mi"&gt;87616&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agree, the numbers vary greatly, so it's not so useless to monitor memory.&lt;/p&gt;

&lt;h1&gt;
  
  
  Dataclasses
&lt;/h1&gt;

&lt;p&gt;Since version 3.7, Python offers data classes. There are several advantages over regular classes or other alternatives, such as returning multiple values or dictionaries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a data class requires a minimal amount of code&lt;/li&gt;
&lt;li&gt;that you can compare data classes because there is "__ eq __"&lt;/li&gt;
&lt;li&gt;you can easily output a data class for debugging because you can use "__ repr __"&lt;/li&gt;
&lt;li&gt;data classes that require type hints, this reduces the likelihood of errors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of a data class in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;dataclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;


&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;


&lt;span class="n"&gt;card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Q"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hearts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# True
&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 'Q'
&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 'hearts'
&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;#Card(rank='Q', suit='hearts')
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Finding the most common value
&lt;/h1&gt;

&lt;p&gt;A fairly simple and elegant example of searching for repetitions in a sequence&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'abracadabra'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'abracadabra'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'abracadabra'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As an argument for Counter, you can pass, for example, list. This will also work.&lt;/p&gt;

&lt;h1&gt;
  
  
  Merging Dictionaries (Python 3.5+)
&lt;/h1&gt;

&lt;p&gt;Starting with Python 3.5, it's easier to combine dictionaries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;dict1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;dict2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;dict1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;dict2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If there are overlapping keys, the keys from the first dictionary will be overwritten.&lt;/p&gt;

&lt;p&gt;In Python 3.9, combining dictionaries becomes even cleaner. The above merge in Python 3.9 can be rewritten as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;dict1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;dict2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dict1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;dict2&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#output
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;The use of some complex (to learn) mechanics in a programming language seems unnecessary to many novice programmers. &lt;br&gt;
But have you ever wondered why more experienced developers use such mechanisms more often?. Simplicity for a beginner and simplicity for a professional are two completely different things. What seems complicated and cumbersome for a beginner is actually the simplest and lightest solution for a more experienced programmer. Each of you will come to these methods and solutions by yourself. Sooner or later. It's just that in our world today, you can learn everything. Let's learn properly!&lt;/p&gt;

&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h3&gt;
  
  
  FAQ
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Facebook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python features you'll want to repeat</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Tue, 16 Nov 2021 15:07:37 +0000</pubDate>
      <link>https://dev.to/abstract/python-features-youll-want-to-repeat-418g</link>
      <guid>https://dev.to/abstract/python-features-youll-want-to-repeat-418g</guid>
      <description>&lt;h2&gt;
  
  
  File server on a computer with mobile access
&lt;/h2&gt;

&lt;p&gt;You can access your file system by running a file server on your computer. Navigate to the desired directory that you want to access and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# python version &amp;gt;=  3.X
&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;
&lt;span class="c1"&gt;# python version &amp;gt;=  3.X
&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="c1"&gt;#for Linux
&lt;/span&gt;
&lt;span class="c1"&gt;# If Python version &amp;gt;= 2.X and &amp;lt; 3.X
&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;SimpleHTTPServer&lt;/span&gt;
&lt;span class="c1"&gt;#default port: 8000
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command starts a file server that can be accessed on the same network. To access your files on a mobile device, simply connect to the same network (Wi-Fi or use the phone's access point on a laptop). Now open the browser in your phone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check your IP by running - &lt;strong&gt;ifconfig&lt;/strong&gt;. Check your local IP&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;192.168.43.155:8000&lt;br&gt;
And on the mobile phone, you will see the current directory&lt;/p&gt;


&lt;h2&gt;
  
  
  Convert CSV to JSON 1 line
&lt;/h2&gt;

&lt;p&gt;If you're a programmer, you'll probably be lazy and want to automate pretty much everything you can, right?&lt;/p&gt;

&lt;p&gt;Don't worry, the python will cover you. There are a lot of things that you can automate in just 4-5 lines of code. From installing cron jobs and reminders to uploading your favorite YouTube videos, you can do it all with a few lines in python.&lt;/p&gt;

&lt;p&gt;Example - convert CSV to JSON&lt;br&gt;
You can convert a CSV file to JSON with just one command in Python!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="s"&gt;"import csv,json;print json.dumps(list(csv.reader(open('your_csv_file.csv'))))"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace it with &lt;em&gt;anyfile.csv&lt;/em&gt; and you will get JSON output!&lt;/p&gt;

&lt;p&gt;Easy, right?&lt;/p&gt;




&lt;h2&gt;
  
  
  Comics
&lt;/h2&gt;

&lt;p&gt;Yes, these are comics in python!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
 &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;antigravity&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--70i0PQ8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blg38mx4cjjnlkabjwl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--70i0PQ8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blg38mx4cjjnlkabjwl1.png" alt="Comics" width="518" height="588"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Will they add brackets in python?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;__future__&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;braces&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;stdin&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="nb"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;chance&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  A simple life lesson
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;this&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;love&lt;/span&gt;  
&lt;span class="bp"&gt;True&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h3&gt;
  
  
  FAQ
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Face....oh...Meta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>jokes</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Soft skills that will improve your work and life. With self-check</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Mon, 15 Nov 2021 20:38:08 +0000</pubDate>
      <link>https://dev.to/abstract/soft-skills-that-will-improve-your-work-and-life-with-self-check-24h6</link>
      <guid>https://dev.to/abstract/soft-skills-that-will-improve-your-work-and-life-with-self-check-24h6</guid>
      <description>&lt;p&gt;Being a programmer in 2021 is not the same as ten years ago. The world is constantly changing, and many of the skills that were important back then have faded into the background over time. And what skills should a developer have in order to remain a sought-after specialist, for example, in five years? If you don't have them, maybe you should think about their development now?&lt;/p&gt;




&lt;p&gt;In this post, I want to talk about skills that will help you stay in demand as a developer even in conditions of constant change. Usually, IT specialists rely on the scientific and technical base, which is important for understanding the functioning of the system as a whole. This includes knowledge of the operating principles of the OS, the network stack, databases, and the mathematical apparatus that underlies any algorithm or protocol, etc. However, hard skills alone are not enough — communication skills, the ability to build a workflow with a team and/or strangers, flexibility in decision-making, and other soft skills are also needed. Moreover, it is important not just to have the — soft skills that should be integrated into the overall development process and go in close conjunction with professional skills. Seven of them will be discussed today.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Comprehensive problem solving
&lt;/h1&gt;

&lt;p&gt;The demand for specialists who are able to approach the task from different sides is steadily growing. Most people cannot solve complex problems because they often use technologies aimed at the process, not the result. A developer using an integrated approach can not only identify the problem, but also determine its causes, and most importantly, "calculate" further steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bn7BRpYb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fp8141tlxdtqi418ckc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bn7BRpYb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fp8141tlxdtqi418ckc.png" alt="Comprehensive problem" width="880" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Colleagues complain about a recurring problem. If it arose in your team, where would you start solving it?&lt;/li&gt;
&lt;li&gt;Do you calculate the possible risks when choosing a certain solution?&lt;/li&gt;
&lt;li&gt;How to understand that you are really solving the problem, and not eliminating its "symptoms"?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. The ability to convince
&lt;/h1&gt;

&lt;p&gt;The ability to convince — that is, to present your idea, make arguments and tell a story so that listeners are passionate - is necessary not only for those who constantly communicate with clients. This skill will help to defend your point of view, inspire like-minded people. And in order for colleagues to listen to you not out of politeness, but attentively and intently, it is highly desirable to make your story not only convincing but also interesting.&lt;/p&gt;

&lt;p&gt;For example: when preparing a presentation about a release, you try not to load your colleagues with a dry list of facts with technical details, but build a story: add explanations, vivid examples, think about how you will manage the attention of listeners, and prepare arguments for answers to possible questions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wpMhzM3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epoaw7d4ri3lv2eqjkez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wpMhzM3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epoaw7d4ri3lv2eqjkez.png" alt="Convince" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have you noticed that you are interrupted at meetings? Was there a feeling that no one was listening to you?&lt;/li&gt;
&lt;li&gt;Do you try to give illustrative cases when defending your point of view?&lt;/li&gt;
&lt;li&gt;How will you start the story about yourself? Rehearse a small speech.&lt;/li&gt;
&lt;li&gt;Remember the case when, after a conversation with you, a colleague changed his mind. What exactly helped you convince him?&lt;/li&gt;
&lt;li&gt;How do you respond to objections?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Cooperation and teamwork skills
&lt;/h1&gt;

&lt;p&gt;I think many will agree that the community plays a significant role in the IT environment: experienced developers help colleagues and willingly share their experiences. Nevertheless, there is a stereotype that it is normal for a programmer to be closed, but it is difficult to interact with a closed person since he almost never offers ideas and is not inclined to discuss current processes. Therefore, more and more companies are paying attention to whether a specialist is able to work in a team, whether he understands colleagues as well as the project itself, whether he is able to give and receive feedback.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n992f1li--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lz364liptut1mirt4rfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n992f1li--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lz364liptut1mirt4rfn.png" alt="Team" width="880" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to talk to a colleague you didn't know before. Where will you start?&lt;/li&gt;
&lt;li&gt;One of the team members repeatedly passes the work with errors. What will you do?&lt;/li&gt;
&lt;li&gt;What words will you choose to make the criticism sound friendly?&lt;/li&gt;
&lt;li&gt;Do you celebrate the successes of your colleagues and talk about them publicly?&lt;/li&gt;
&lt;li&gt;What helps you feel the mood of the interlocutor and tune in to his wave?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  4. Ability to plan your work
&lt;/h1&gt;

&lt;p&gt;Employers value specialists who are able to plan, give accurate estimates of the complexity of tasks and adhere to deadlines regardless of the language, technologies, and methodologies used.&lt;/p&gt;

&lt;p&gt;Example: to organize the work of a group (if you are a leader) or your own, you plan sprints, make sure that there is a time interval between the task and the solution, which will allow you to organize things and prioritize. During the day, you stick to what you have planned and do not get distracted by other requests so that the work becomes more calm and predictable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ouTGVo2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5asuy6cdzumda2xj36e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ouTGVo2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5asuy6cdzumda2xj36e.png" alt="Time Management" width="880" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are asked to name the deadlines for the project's readiness. What will guide you in the assessment?&lt;/li&gt;
&lt;li&gt;It's the middle of the working day, and suddenly a colleague sends you a link. You know that there is a useful and important article there. What will you do?&lt;/li&gt;
&lt;li&gt;Do you make work and personal plans for the day/week/month? How many of them can be completed?&lt;/li&gt;
&lt;li&gt;Are you familiar with the Eisenhower matrix time planning method?&lt;/li&gt;
&lt;li&gt;Do you know how much time it takes you on average for each type of task?&lt;/li&gt;
&lt;li&gt;How many minutes/hours a day do you spend on social media? Do you track these statistics in any way? Do you use time trackers?&lt;/li&gt;
&lt;li&gt;Do you practice taking a break from social networks and the Internet, digital detox?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  5. Critical thinking
&lt;/h1&gt;

&lt;p&gt;The ability to think critically is one of the key skills in our time. In a world where knowledge is power and the flow of information increases exponentially, you need to be able to ask questions, compare data and be critical of what others write. If we talk about professional development, critical thinking allows you to determine which set of skills you need. Someone needs clean code, knowledge of the version control system, and system thinking to work, and someone who is engaged in high-tech projects needs deep immersion in special sections of mathematics or physics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GbqbzQvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jan3jd8cdxc5ve6q5lbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GbqbzQvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jan3jd8cdxc5ve6q5lbu.png" alt="Thinking" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do you think when reading materials on the Internet about who publishes them and for what purpose?&lt;/li&gt;
&lt;li&gt;How do you determine which information can be trusted? What criteria do you rely on when choosing information sources?&lt;/li&gt;
&lt;li&gt;Do you check website addresses and connection security when clicking on unfamiliar links?&lt;/li&gt;
&lt;li&gt;Do you have a list of trusted sources of information?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  6. Continuous learning — long life learning
&lt;/h1&gt;

&lt;p&gt;Many leading companies seek to hire full-stack developers who work freely with different technologies and platforms. Such specialists understand the principles of any development, starting from the network core level and ending with the interface level. This is impossible to achieve if you do not make it a rule to constantly learn new things. A sought-after developer is determined not only by the possession of a rare stack but also by the ability to easily "switch" between different languages and the desire to learn new tools every day.For example: although Java and C# have occupied a significant part of the market for several years, IT companies are increasingly using newer technologies (Kotlin, Swift, etc.). And, logically, developers who are proficient in several languages will give odds to those who are familiar with one or two technologies. In five years, new stacks will surely appear, so to remain in demand, it is important to constantly learn and be able to choose the right tool for solving a specific task, based on a comprehensive analysis of factors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4yRUDUpe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tu5uxls1jh6vf5vi13mb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4yRUDUpe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tu5uxls1jh6vf5vi13mb.png" alt="Learning" width="880" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do you participate in the development of open-source projects? How many commits have you made over the past year? How many bugs and suggestions have you created in the tracker? How many questions were answered?&lt;/li&gt;
&lt;li&gt;How long have you been studying an unfamiliar technology for yourself?&lt;/li&gt;
&lt;li&gt;What would you do if you found out about the emergence of a new language that is gaining popularity?&lt;/li&gt;
&lt;li&gt;How do you react if you are offered to go to a training event?&lt;/li&gt;
&lt;li&gt;What professional conferences do you attend?&lt;/li&gt;
&lt;li&gt;What have you learned in your professional field over the past six months?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  7. Compliance with work-life balance
&lt;/h1&gt;

&lt;p&gt;Compliance with work-life balance and your well-being directly affect productivity: those who take care of themselves usually live longer, work more efficiently and have time to pay due attention to other important matters. The topic of health is closely connected with all spheres of life, including work. I won't say anything about biohacking and implanting chips under the skin (this is the topic of a separate post — or even more than one), this item is more about attention to the body, to the psycho-emotional state, and also that the separation of personal and professional life helps them mutually support each other. Try to be more tolerant of others, especially if their point of view contradicts yours, express feelings without harming others, and be aware of what you can influence and what you can't. Find a hobby to your liking and remember that your career success will partly depend on how your life is organized after work and study.&lt;/p&gt;

&lt;p&gt;For example: in order to feel cheerful and have more time, you go to bed on time, do not use the phone two hours before bedtime and do not grab it first thing in the morning, do not overeat. Thanks to this, you stay attentive and energetic longer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4IDAaTfp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cc0jekhb0eaxa43bxoei.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4IDAaTfp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cc0jekhb0eaxa43bxoei.png" alt="Work-life" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-test:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When was the last time you underwent a comprehensive examination?&lt;/li&gt;
&lt;li&gt;What do you do to ensure that your diet is balanced?&lt;/li&gt;
&lt;li&gt;How many hours a day do you sleep? Do you get enough sleep? If not, what can you do now to improve the quality of your sleep?
In the morning you feel cold, but you need to go to work. What will you do?&lt;/li&gt;
&lt;li&gt;Do you work on vacation? Do you finish projects on weekends? Do you write to work chats in the evenings?&lt;/li&gt;
&lt;li&gt;What are your hobbies? Have you been interested in something new for yourself for a long time?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This skill set does not appear with birth and is not strictly mandatory. But the development of these skills will not only give you success in work or in a team but will also make your life much better.&lt;/p&gt;

&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;




&lt;h4&gt;
  
  
  FAQ
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can we cooperate with you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have interesting projects and you need a python (web)developer, then you can contact me by &lt;strong&gt;&lt;a href="//titanyforgame@gmail.com"&gt;mail&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://discord.gg/szEuVAhatW"&gt;discord&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/vadzim-hlobuz-0b44531b7/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt; for cooperation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Face....oh...Meta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>motivation</category>
      <category>leadership</category>
    </item>
    <item>
      <title>Instructive Python code examples for Beginners</title>
      <dc:creator>Vadim Kolobanov</dc:creator>
      <pubDate>Wed, 10 Nov 2021 20:09:30 +0000</pubDate>
      <link>https://dev.to/abstract/instructive-python-code-examples-p8a</link>
      <guid>https://dev.to/abstract/instructive-python-code-examples-p8a</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@pakata?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Pakata Goh&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/python?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi guys! I want to show you beautiful and instructive python code examples. Using them in training, you will discover new language features and your code will look more professional.&lt;br&gt;
Let's get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. We get vowels&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example returns the found vowels "a e i o u" in the string. This can be useful when searching for or detecting vowels.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_vowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s"&gt;"aeiou"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;get_vowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"animal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [a, i, a]
&lt;/span&gt;&lt;span class="n"&gt;get_vowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sky"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# []
&lt;/span&gt;&lt;span class="n"&gt;get_vowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"football"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [o, o, a]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. The first letter in uppercase&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This works with a string of one or more characters and will be useful when analyzing text or writing data to a file. You can refine this code and make all letters uppercase to use case-independent search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"shop"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [Shop]
&lt;/span&gt;&lt;span class="n"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"python programming"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [Python Programming]
&lt;/span&gt;&lt;span class="n"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"how are you!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [How Are You!]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Print the line N times&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Loops are a hard part of the language. You don't have to use them to output strings.&lt;/p&gt;

&lt;p&gt;Look how it's easy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Hello World "&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;#Hello World Hello World Hello World Hello World Hello World
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Combine two dictionaries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many of you guys, in order to combine 2 sequences, start overwriting one into the other. And again cycles, conditions, append and other horror... Catch a life hack, and please learn correctly!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dic1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dic2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;dic1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;dic2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;dic1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Dev"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;dic2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Programming"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# In these examples, Python merges dictionary keys
# in the order listed in the expression, overwriting 
# duplicates from left to right.
&lt;/span&gt;&lt;span class="n"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dic1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dic2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# {1: 'Hello', 2: 'Dev', 3: 'Python', 4: 'Programming'}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Calculate the execution time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example is useful when you need to know how long it takes to execute a program or function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;
&lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fun&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="n"&gt;fun&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;end_time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;timetaken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;end_time&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start_time&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Your program takes: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timetaken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# 0.0345
# I love you Dev =) 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Exchange of values between variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Learn to use fewer variables guys. This option will look more elegant&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a= 4, b =3
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Checking duplicates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here I draw attention once again to the fact that set contains immutable data. Just remember this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_duplicate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;check_duplicate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# True
&lt;/span&gt;&lt;span class="n"&gt;check_duplicate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# False
&lt;/span&gt;&lt;span class="n"&gt;check_duplicate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# False
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. Filtering False values (or other)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An easy way to remove values from the list. Beautiful, elegant, and will show your code as the work of a professional.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;Filtering&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;Filtering&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#[1, 3, 5, 7]
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9. Size in bytes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example returns the length of a string in bytes, which is convenient when you need to know the size of a string variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ByteSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"utf8"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ByteSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Python"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#6
&lt;/span&gt;&lt;span class="n"&gt;ByteSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Data"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#4
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;10. Load memory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It will be useful if you want to keep track of the memory that your variables occupy. The main thing is to remember:&lt;br&gt;
&lt;strong&gt;Simple is better than complex.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Complex is better than complicated.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Python"&lt;/span&gt;
&lt;span class="n"&gt;var2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="n"&gt;var3&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;#55
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;#28
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;#28
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;does not work with a recursive function&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Anagrams&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This code is useful for finding Anagrams. An anagram is a word obtained by rearranging the letters of another word.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;anagrams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;str2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;anagrams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"abc1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1bac"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# True
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;12. Sorting the list&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example sorts the list. Sorting is a frequently used task that can be implemented with many lines of code with a loop, but you can speed up your work using the built-in sorting method. Study Python deeper! And you will be happy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="n"&gt;my_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"leaf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"cherry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"fish"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;my_list1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"D"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"C"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;my_list2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# ['cherry', 'fish', 'leaf']
&lt;/span&gt;&lt;span class="n"&gt;my_list1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# ['A', 'B', 'C', 'D']
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# [5, 4, 3, 2, 1]
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;13. Converting a comma-separated list to a string&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This code converts a comma-separated list into a single string. It is very convenient to list all the values of the list in one line. And besides, JOIN is a useful method in python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;my_list1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"C++"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;my_list2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Java"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Flutter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Swift"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="c1"&gt;#example 1
&lt;/span&gt;&lt;span class="s"&gt;"My favourite Programming Languages are"&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;", "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;#My favourite Programming Languages are Python, JavaScript, C++
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;", "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# Java, Flutter, Swift
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;14. Shuffling the list&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everything is clear from the name here. But you didn't know that, did you? Really?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;random&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;shuffle&lt;/span&gt;
&lt;span class="n"&gt;my_list1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;my_list2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"C"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"D"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [4, 6, 1, 3, 2, 5]
&lt;/span&gt;&lt;span class="n"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# ['A', 'D', 'B', 'C']
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;15 Splitting into fragments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example will show how to split the list into fragments and divide it into smaller parts. Not so useful, but interesting&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="n"&gt;my_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# [[1, 2], [3, 4], [5, 6]]
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Put on Heart if you liked it and you learned something new!
&lt;/h3&gt;
&lt;h3&gt;
  
  
  You can also follow &lt;a href="https://dev.to/vadimkolobanov"&gt;ME&lt;/a&gt; to receive notifications about new interesting articles.
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  FAQ
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;I am a beginner, how should I learn Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look into the following series:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/vadimkolobanov/series/15329"&gt;Learning Python&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15349"&gt;Step by Step to Junior&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/vadimkolobanov/series/15331"&gt;Ideas&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Would you mentor me?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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. &lt;strong&gt;Write to discord, please. We have a discord community for you&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Would you like to collaborate on our organization?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you have interesting projects and you need a backend developer, then you can contact me by mail or in discord for cooperation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to me on&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.facebook.com/neo.skarynsky"&gt;Write me on Face....oh...Meta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/decodesperato"&gt;My Twitter&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Discord: vadimkolobanov#5875&lt;/p&gt;

&lt;h2&gt;
  
  
  Be responsive! Mark your interest in others and others will mark you!
&lt;/h2&gt;

</description>
      <category>programming</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>python</category>
    </item>
  </channel>
</rss>
