11 astonishing concepts of python
Tags: python, programmer, developer, learning
Published: 2020-04-04 13:09:19

<p><span style="font-weight: 400;">Hey, you are at the right place if you want to learn the most important concepts of python. So, without any further delay let's get a dive into it&hellip;..</span></p>
<p>&nbsp;</p>
<p><strong>Many programming languages come and go, but only the strong one survives in the industry. Yes, we are talking about python! </strong><span style="font-weight: 400;">It is constantly rising in the industry and has proved to be known as one of the top programming languages in the world right now.</span></p>
<p>&nbsp;</p>
<p><strong>Python ranked #1 on the IEEE Spectrum list</strong><span style="font-weight: 400;"> of top programming languages for 2019.</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">Top organizations of the world like </span><strong>Dropbox, Google, Quora, Mozilla, Hewlett-Packard, Qualcomm, IBM, and Cisco have shown faith in python.</strong></p>
<p><br /><br /></p>
<p><span style="font-weight: 400;">According to</span><strong> Stack overflow python is the most popular language in 2020</strong></p>
<p><br /><br /></p>
<p><span style="font-weight: 400;">As a Python expert, I believe that there are certain vital concepts or facts that every Python developer should know. All these were necessary concepts within the time I learned using Python as my foremost programming language.</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">Let&rsquo;s get started with </span><strong>11 concepts of Python you must learn&hellip;.</strong></p>
<ol>
<li style="font-weight: 400;">
<h3><span style="font-weight: 400;">Operators</span></h3>
</li>
</ol>
<p><span style="font-weight: 400;">Operators are special symbols that carry out operations on operands.</span></p>
<p><span style="font-weight: 400;">Let's explore arithmetic and assignment operators :</span></p>
<p>&nbsp;</p>
<p><strong>Arithmetic operators</strong><span style="font-weight: 400;"> are used to performing mathematical operations like addition, subtraction, multiplication, etc.</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">For example:</span></p>
<p><span style="font-weight: 400;">x = 14</span></p>
<p><span style="font-weight: 400;">y = 4</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;"># Add two operands</span></p>
<p><span style="font-weight: 400;">print('x + y =', x+y) # Output: x + y = 18</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;"># Subtract right operand from the left</span></p>
<p><span style="font-weight: 400;">print('x - y =', x-y) # Output: x - y = 10</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;"># Multiply two operands</span></p>
<p><span style="font-weight: 400;">print('x * y =', x*y) # Output: x * y = 56</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;"># Divide left operand by the right one&nbsp;</span></p>
<p><span style="font-weight: 400;">print('x / y =', x/y) # Output: x / y = 3.5</span></p>
<p>&nbsp;</p>
<p><strong>Assignment operators</strong><span style="font-weight: 400;"> are used to assigning values to variables. Let's try some more assignment operators.</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">For example:</span></p>
<p><span style="font-weight: 400;">x = 5</span></p>
<p><span style="font-weight: 400;"># x += 5 ----&gt; x = x + 5</span></p>
<p><span style="font-weight: 400;">x +=5</span></p>
<p><span style="font-weight: 400;">print(x) # Output: 10</span></p>
<p><span style="font-weight: 400;"># x /= 5 ----&gt; x = x / 5</span></p>
<p><span style="font-weight: 400;">x /= 5</span></p>
<p><span style="font-weight: 400;">For detailed knowledge visit</span><a href="https://data-flair.training/blogs/python-operator/"> <em><span style="font-weight: 400;">Python Operators</span></em></a> <span style="font-weight: 400;">and learn about all operators in detail.</span></p>
<ol>
<li style="font-weight: 400;">
<h3><span style="font-weight: 400;">More about String</span></h3>
</li>
</ol>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">A Python string is a sequence of characters.</span></p>
<p><span style="font-weight: 400;">Python doesn&rsquo;t have the char data-type as C++ or Java does</span></p>
<p><span style="font-weight: 400;">You can declare a Python string using either single quotes or double-quotes.</span></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">&gt;&gt;&gt; a='python is love'</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">&gt;&gt;&gt; print(a)</span></li>
</ol>
<p><span style="font-weight: 400;">Python is love</span></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">&gt;&gt;&gt; a="python is love"</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">&gt;&gt;&gt; print(a)</span></li>
</ol>
<p><span style="font-weight: 400;">Python is love.</span></p>
<p><span style="font-weight: 400;">know more about </span><a href="https://data-flair.training/blogs/python-string/"><em><span style="font-weight: 400;">strings and different types of strings</span></em></a><span style="font-weight: 400;">.</span></p>
<h3><span style="font-weight: 400;">3. Python Iterators</span></h3>
<p><span style="font-weight: 400;">A Python iterator returns us an iterator object- one value at a time. Let&rsquo;s take an example of an iterator in python.</span></p>
<p><span style="font-weight: 400;">&gt;&gt;&gt; iter_obj=iter([3,4,5])</span></p>
<p><span style="font-weight: 400;">&gt;&gt;&gt; next(iter_obj)</span></p>
<p><span style="font-weight: 400;">3</span></p>
<p><span style="font-weight: 400;">&gt;&gt;&gt; next(iter_obj)</span></p>
<p><span style="font-weight: 400;">4</span></p>
<p><span style="font-weight: 400;">&gt;&gt;&gt; next(iter_obj)</span></p>
<p><span style="font-weight: 400;">5</span></p>
<p><span style="font-weight: 400;">&gt;&gt;&gt; next(iter_obj)</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">Traceback (most recent call last):</span></p>
<p><span style="font-weight: 400;">File &ldquo;&lt;pyshell#560&gt;&rdquo;, line 1, in &lt;module&gt;</span></p>
<p><span style="font-weight: 400;">next(iter_obj)</span></p>
<p><span style="font-weight: 400;">StopIteration</span></p>
<p><span style="font-weight: 400;">For more details, check our </span><a href="https://data-flair.training/blogs/python-iterator/"><em><span style="font-weight: 400;">Python Iterator tutorial</span></em></a><em><span style="font-weight: 400;">.</span></em></p>
<h3><span style="font-weight: 400;">4. Python loops</span></h3>
<p><span style="font-weight: 400;">When you want some statements to execute a hundred times, you don&rsquo;t repeat them 100 times. Think of when you want to print numbers 1 to 99. Or that you want to say Hello to 99 friends. In such a case, you can use loops in python.</span></p>
<p><span style="font-weight: 400;">Here, we will discuss 4 types of Python Loop:</span></p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">Python For Loop</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Python While Loop</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Python Loop Control Statements</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Nested For Loop in Python</span></li>
</ul>
<p><span style="font-weight: 400;">Study all about </span><a href="https://data-flair.training/blogs/python-loop/"><em><span style="font-weight: 400;">&ldquo;Loops</span></em></a><em><span style="font-weight: 400;">&rdquo;</span></em><span style="font-weight: 400;"> which consists of detailed information regarding For Loop, Python While Loop, Python Loop Control Statements, and Nested For Loop in Python with their subtypes, syntax, and examples.</span></p>
<h3><span style="font-weight: 400;">5. Python constructors</span></h3>
<p><span style="font-weight: 400;">Python Constructor in </span><a href="https://data-flair.training/blogs/python-classes/"><span style="font-weight: 400;">object-oriented programming with Python</span></a><span style="font-weight: 400;"> is a special kind of method/function we use to initialize instance members of that class. We can also use it to ensure we have enough resources. Whenever we create an object of that </span><a href="https://data-flair.training/blogs/python-class/"><span style="font-weight: 400;">class</span></a><span style="font-weight: 400;">, the constructor definition is the first to execute.</span></p>
<p><span style="font-weight: 400;">Let's learn more about</span><a href="https://data-flair.training/blogs/python-constructor/"> <em><span style="font-weight: 400;">python constructor</span></em></a><em><span style="font-weight: 400;">.</span></em></p>
<h3><span style="font-weight: 400;">6. Python exception handling</span></h3>
<p><span style="font-weight: 400;">Python has many built-in exceptions that force your program to output an error when something in it goes wrong. When these exceptions occur, it causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash.</span></p>
<p><span style="font-weight: 400;">For example, if function A calls function B which in turn calls function C and an exception occurs in function C. If it is not handled in C, the exception passes to B and then to A.</span></p>
<p><span style="font-weight: 400;">If never handled, an error message is spit out and our program come to a sudden, unexpected halt</span></p>
<p><span style="font-weight: 400;">Let&rsquo;s understand more about </span><a href="https://data-flair.training/blogs/python-exception-handling/"><em><span style="font-weight: 400;">python exception handling</span></em></a><em><span style="font-weight: 400;">.</span></em></p>
<p>&nbsp;</p>
<h3><span style="font-weight: 400;">7. Lambda Functions</span></h3>
<p><span style="font-weight: 400;">Lambda functions are referred to as unknown functions. It fits for easy operations.</span></p>
<p><span style="font-weight: 400;">def say_hello():</span></p>
<p><span style="font-weight: 400;">return "hello"&nbsp;</span></p>
<p><span style="font-weight: 400;">#or&nbsp;</span></p>
<p><span style="font-weight: 400;">say_hello = lambda:"hello"</span></p>
<p><span style="font-weight: 400;">Read more about</span><a href="https://data-flair.training/blogs/python-lambda-expression/"> <em><span style="font-weight: 400;">lambda functions.</span></em></a></p>
<p>&nbsp;</p>
<h3><span style="font-weight: 400;">8. Python regular expression</span></h3>
<p><span style="font-weight: 400;">Python regular expression is a sequence of characters that defines a search pattern.&nbsp;</span></p>
<p><span style="font-weight: 400;">In </span><a href="https://data-flair.training/blogs/python-regex-tutorial/"><span style="font-weight: 400;">Python Regex tutorial</span></a><span style="font-weight: 400;">, you will learn the basics of regular expressions in Python.</span></p>
<p>&nbsp;</p>
<h3><span style="font-weight: 400;">9. Python functions</span></h3>
<p><span style="font-weight: 400;">Python function in any programming language is a sequence of statements in a certain order, given a name.&nbsp;</span></p>
<h3><span style="font-weight: 400;">Know about different </span><a href="https://data-flair.training/blogs/python-function/"><em><span style="font-weight: 400;">types of functions in Python</span></em></a><span style="font-weight: 400;">: Python built-in functions, Python recursion function, Python lambda function, and Python user-defined functions with their syntax and examples.</span></h3>
<p>&nbsp;</p>
<h3><span style="font-weight: 400;">1O. Data Structures: List, Set, Dictionary</span></h3>
<p><span style="font-weight: 400;">There are quite a few data structures available. The builtins data structures are lists, tuples, dictionaries, strings, sets, and frozen sets.</span></p>
<p><span style="font-weight: 400;">Lists are enclosed in brackets:</span></p>
<p><span style="font-weight: 400;">l = [1, 2, "a"]</span></p>
<p><span style="font-weight: 400;">Tuples are enclosed in parentheses:</span></p>
<p><span style="font-weight: 400;">t = (1, 2, "a")</span></p>
<p><span style="font-weight: 400;">Tuples are faster and consume less memory.&nbsp;</span></p>
<p><span style="font-weight: 400;">Dictionaries are built with curly brackets:</span></p>
<p><span style="font-weight: 400;">d = {"a":1, "b":2}</span></p>
<p><span style="font-weight: 400;">Learn more about data structures.</span></p>
<h3><span style="font-weight: 400;">&nbsp;11. Python Decision Making Statements &ndash; Python If, If-else, Nested Statements</span></h3>
<p><span style="font-weight: 400;">Sometimes, in a program, we may want to make a decision based on a condition. We know that an expression&rsquo;s value can be True or False. We may want to do something only when a certain condition is true. For example, assume variables a and b. If a is greater, then we want to print &ldquo;a is greater&rdquo;. Otherwise, we want to print &ldquo;b is greater&rdquo;. For this, we use an if-statement. Also, operators come in handy when you want to join conditions to make a composite one.</span></p>
<p><span style="font-weight: 400;">Study in-depth about </span><a href="https://data-flair.training/blogs/python-decision-making-expressions/"><em><span style="font-weight: 400;">python decision making.</span></em></a></p>
<p><span style="font-weight: 400;">Learning doesn&rsquo;t have any limits.</span></p>
<p><a href="https://data-flair.training/blogs/learn-python-notes/"><em><span style="font-weight: 400;">Learn python through the master guide</span></em></a><em><span style="font-weight: 400;">.</span></em></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">&nbsp;&nbsp;</span></p>
<p><span style="font-weight: 400;">So there are always endless topics that you will find about programming. But if we talk about some of the important concepts that you need to cover about python are covered in this article.&nbsp;</span></p>
<p><br /><br /></p>
<p><span style="font-weight: 400;">Thank You!&nbsp;</span></p>
<p><em><span style="font-weight: 400;">Happy- learning&hellip;&hellip;.</span></em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>