<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Parthpritam on Medium]]></title>
        <description><![CDATA[Stories by Parthpritam on Medium]]></description>
        <link>https://medium.com/@parthpritam7631?source=rss-9993b0799531------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pRuzEmA04o369pg3.jpg</url>
            <title>Stories by Parthpritam on Medium</title>
            <link>https://medium.com/@parthpritam7631?source=rss-9993b0799531------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:42:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parthpritam7631/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[TYPESCRIPTS]]></title>
            <link>https://medium.com/@parthpritam7631/typescripts-7165fc020590?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/7165fc020590</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 07:16:12 GMT</pubDate>
            <atom:updated>2022-06-28T07:16:12.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yosx8MZW2A4U_1bKJnElKw.jpeg" /></figure><h3>TypeScript for Python Developers</h3><h3>A quick introduction to TypeScript for experienced Python developers</h3><p>If you already know Python, you might be interested in learning TypeScript. It is getting more and more popular. It works in your browser. And in many facets, it is a very similar language.</p><p>However, most places to learn a programming language are focused on new developers. Very few articles or tutorials cut down to the essentials of the new language while leaving out the basic of programming. This article will provide a brief but dense overview how TypeScript works, and how you can get started easily. It contains the basic syntax, loops, types, shorthands are more.</p><h3>The basics</h3><p>TypeScript is a superset of Javascript. So any Javascript code is valid TypeScript code but not the other way around. TypeScript compiles into JavaScript code, which can then be interpreted by the executor, a browser or NodeJS.</p><p>TypeScript can be used as a front end language, generally as part of a framework or library. Or as a backend with node.js, often as a webserver but in theory also as a pure backend.</p><h3>Syntax</h3><p>Like most other languages, TypeScript uses brackets to create scopes, versus Python’s indentation based style. CamelCase TypeScript is also the convention versus Python’s snake_case .</p><h3>Basics</h3><p>Here are a list of basics to get started, first as Python code and then TypeScript code. I’ll use Python’s typing to compare to TypeScripts typing.</p><h3>Assignments</h3><p>First of all, assignment in TypeScript is done with a keyword. There are three key words: var, let and const. Learning this is quite easy: use const if the value is a constant and won’t change, use let is the value is going to change and don’t use var . The reason to not use var is about <a href="https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/">variable scoping</a>, and is not covered here.</p><h3>Types</h3><p>These compare <em>mypy</em> types with <em>TypeScript</em>. The format is <em>Python — TypeScript</em>. A complete list of TypeScript types can be found <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html">here</a>.</p><ul><li>int, float, double, long<em> — </em>number</li><li>str <em>— </em>string</li><li>List[T]<em> — </em>Array&lt;T&gt;<em> </em>or T[], with T being any other type</li><li>Dict <em>— </em>Object</li><li>Tuple[str, int, dict]<em>— </em>[string, number, object]</li><li>TypedDict<em>— </em>Custom interface</li></ul><p>TypeScript and JavaScript only has one types for numbers without a specific reference to integers or floats. In some sense it makes sense, but makes casting to integers annoying.</p><p>While talking about types, someone cannot skip the two different empty values in TypeScript: null<em> </em>and undefined<em>.</em></p><ul><li>null denotes an non-existing <strong>object</strong> or the fact that there is no input. It can be compared to Python’s None.</li><li>undefined is returned when an attribute is referenced that does not exist. It is similar to Python’s KeyError or AttributeError.</li></ul><p>TypeScript doesn’t error out if you reference an non-existing value on an object. However, referencing anything on undefined does throw a TypeError. Both are falsy, and <em>undefined</em> i snot equal to null.</p><h3>Conclusion</h3><h3>The good</h3><ul><li>The TypeScript compiler and typechecker feels much better than mypy. For VS Code it also seems to have better compatability</li><li>Null checking is super usefull, especially when working with user data.</li><li>The shorthands can safe a lot of time</li><li>It’s basically the only language accepted in a browser, and can also be used on a server. This allows for full JS/TS stacks</li><li>I had a lot of fun with RxJS, which forced me to think in a functional way</li><li>It’s a very flexible language (like Python), so you can always find a style that suits you</li><li>A lot of libraries and a huge community</li></ul><h3>The bad</h3><ul><li>Working with dates is really a pain in the ass, especially coming from datetime and dateutil</li><li>Running a script is slightly more annoying as you can’t just to <em>python script.py</em></li><li>Some of the libraries are not as high quality as some in Python</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7165fc020590" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DECORATORS IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/decorators-in-python-1d68f5f0d1ea?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d68f5f0d1ea</guid>
            <category><![CDATA[decorators]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 06:45:15 GMT</pubDate>
            <atom:updated>2022-06-28T06:45:15.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yosx8MZW2A4U_1bKJnElKw.jpeg" /></figure><p>A decorator in Python is a function that takes another function as an argument and extends its behavior without explicitly modifying it. It is one of the most powerful features of Python. It has several usages in the real world like logging, debugging, authentication, measuring execution time, and many more.</p><h3>Introduction</h3><p>Suppose, you have a set of functions and you only want authenticated users to access them.<br>Therefore, you need to check whether a user is authenticated or not before proceeding with the rest of the code in the function.</p><p>One way to do this is by calling a separate function inside all the functions and using conditional statements. But this will require us to change the code for each function.<br>A better solution here would be to use a <strong>Decorator</strong>.</p><p><em>A Decorator is just a function that takes another function as an argument and extends its behavior without explicitly modifying it</em>.</p><p>This means that a decorator adds new functionality to a function.</p><p>By the end of this article, you will understand what does “extending a function without actually modifying it” means.</p><h3>Introduction to Decorators</h3><p>Now that we have the pre-requisite knowledge for understanding decorators, let’s go on to learn about Python decorators.</p><p>As discussed before, a decorator in Python is used to modify the behavior of a function without actually changing it.</p><p><strong>Syntax:</strong></p><pre>func = decorator(func)</pre><p>where func is the function being decorated and decorator is the function used to decorate it.</p><p>Let’s see an example to understand what does this mean:</p><pre>def decorator(func):<br>  def wrapper():<br>    print(&quot;This is printed before the function is called&quot;)<br>    func()<br>    print(&quot;This is printed after the function is called&quot;)<br>  <br>  return wrapper</pre><pre>def say_hello():<br>  print(&quot;Hello! The function is executing&quot;)<br></pre><pre>say_hello = decorator(say_hello)</pre><pre>say_hello()</pre><p><strong>Output:</strong></p><pre>This is printed before the function is called<br>Hello! The function is executing<br>This is printed after the function is called</pre><p><strong>Explanation:</strong></p><p>We have two functions here:</p><ul><li><strong>decorator</strong>: This is a decorator function, it accepts another function as an argument and “decorates it” which means that it modifies it in some way and returns the modified version.<br>Inside the decorator function, we are defining another inner function called wrapper. This is the actual function that does the modification by wrapping the passed function func.<br>decorator returns the wrapper function.</li><li><strong>say_hello</strong>: This is an ordinary function that we need to decorate. Here, all it does is print a simple statement.</li></ul><p>The most important line in the code is this:</p><pre>say_hello = decorator(say_hello)</pre><p>We passed the say_hello function to the decorator function. In effect, the say_hello now points to the wrapper function returned by the decorator.<br>However, the wrapper function has a reference to the original say_hello() as func, and calls that function between the two calls to print().</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d68f5f0d1ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SYNCHRONIZATION IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/synchronization-in-python-89a333231054?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/89a333231054</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[synchronization]]></category>
            <category><![CDATA[multithreading]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 06:38:36 GMT</pubDate>
            <atom:updated>2022-06-28T06:38:36.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yosx8MZW2A4U_1bKJnElKw.jpeg" /></figure><p>Thread synchronization may be defined as a method with the help of which we can be assured that two or more concurrent threads are not simultaneously accessing the program segment known as critical section. On the other hand, as we know that critical section is the part of the program where the shared resource is accessed. Hence we can say that synchronization is the process of making sure that two or more threads do not interface with each other by accessing the resources at the same time. The diagram below shows that four threads trying to access the critical section of a program at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*TzCtAmMRYRI_6Y-5.jpg" /></figure><p>A <strong>thread</strong> is an entity within a process that can be scheduled for execution. Also, it is the smallest unit of processing that can be performed in an OS (Operating System).</p><p>In simple words, a <strong>thread</strong> is a sequence of such instructions within a program that can be executed independently of other code. For simplicity, you can assume that a thread is simply a subset of a process!</p><p>A thread contains all this information in a <strong>Thread Control Block (TCB)</strong>:</p><ul><li><strong>Thread Identifier:</strong> Unique id (TID) is assigned to every new thread</li><li><strong>Stack pointer:</strong> Points to thread’s stack in the process. Stack contains the local variables under thread’s scope.</li><li><strong>Program counter:</strong> a register which stores the address of the instruction currently being executed by thread.</li><li><strong>Thread state:</strong> can be running, ready, waiting, start or done.</li><li><strong>Thread’s register set:</strong> registers assigned to thread for computations.</li><li><strong>Parent process Pointer:</strong> A pointer to the Process control block (PCB) of the process that the thread lives on.</li></ul><p><strong>Multithreading</strong></p><p>Multiple threads can exist within one process where:</p><ul><li>Each thread contains its own <strong>register set</strong> and <strong>local variables (stored in stack)</strong>.</li><li>All thread of a process share <strong>global variables (stored in heap)</strong> and the <strong>program code</strong>.</li></ul><p><strong>Multithreading in Python</strong></p><p>In Python, the <strong>threading</strong> module provides a very simple and intuitive API for spawning multiple threads in a program.</p><p>Let us consider a simple example using threading module:</p><p># Python program to illustrate the concept</p><p># of threading</p><p># importing the threading module</p><p><strong>import</strong> threading</p><p><strong>def</strong> print_cube(num):</p><p>&quot;&quot;&quot;</p><p>function to print cube of given num</p><p>&quot;&quot;&quot;</p><p>print(&quot;Cube: {}&quot;.format(num <strong>*</strong> num <strong>*</strong> num))</p><p><strong>def</strong> print_square(num):</p><p>&quot;&quot;&quot;</p><p>function to print square of given num</p><p>&quot;&quot;&quot;</p><p>print(&quot;Square: {}&quot;.format(num <strong>*</strong> num))</p><p><strong>if</strong> __name__ <strong>==</strong> &quot;__main__&quot;:</p><p># creating thread</p><p>t1 <strong>=</strong> threading.Thread(target<strong>=</strong>print_square, args<strong>=</strong>(10,))</p><p>t2 <strong>=</strong> threading.Thread(target<strong>=</strong>print_cube, args<strong>=</strong>(10,))</p><p># starting thread 1</p><p>t1.start()</p><p># starting thread 2</p><p>t2.start()</p><p># wait until thread 1 is completely executed</p><p>t1.join()</p><p># wait until thread 2 is completely executed</p><p>t2.join()</p><p># both threads completely executed</p><p>print(&quot;Done!&quot;)</p><pre>Square: 100<br>Cube: 1000<br>Done!</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89a333231054" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[COLLECTIONS IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/collections-in-python-17af4333c509?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/17af4333c509</guid>
            <category><![CDATA[collection]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 06:27:40 GMT</pubDate>
            <atom:updated>2022-06-28T06:27:40.889Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yosx8MZW2A4U_1bKJnElKw.jpeg" /></figure><p>Python’s <a href="https://docs.python.org/3/library/collections.html#module-collections">collections</a> module provides a rich set of <strong>specialized container data types</strong> carefully designed to approach specific programming problems in a Pythonic and efficient way. The module also provides wrapper classes that make it safer to create custom classes that behave similar to the built-in types dict, list, and str.</p><h3>Getting Started With Python’s collections</h3><p>Back in <a href="https://docs.python.org/3/whatsnew/2.4.html#new-improved-and-deprecated-modules">Python 2.4</a>, <a href="https://twitter.com/raymondh">Raymond Hettinger</a> contributed a new module called <a href="https://docs.python.org/3/library/collections.html#module-collections">collections</a> to the <a href="https://docs.python.org/3/library/index.html">standard library</a>. The goal was to provide various specialized collection data types to approach specific programming problems.</p><p>At that time, collections only included one data structure, <strong>deque</strong>, which was specially designed as a <a href="https://en.wikipedia.org/wiki/Double-ended_queue">double-ended queue</a> that supports efficient <strong>append</strong> and <strong>pop</strong> operations on either end of the sequence. From this point on, several modules in the standard library took advantage of deque to improve the performance of their classes and structures. Some outstanding examples are <a href="https://docs.python.org/3/library/queue.html#module-queue">queue</a> and <a href="https://docs.python.org/3/library/threading.html#module-threading">threading</a>.</p><p>The need for these wrapper classes was partially eclipsed by the ability to subclass the corresponding standard built-in data types. However, sometimes using these classes is safer and less error-prone than using standard data types.</p><p>With this brief introduction to collections and the specific use cases that the data structures and classes in this module can solve, it’s time to take a closer look at them. Before that, it’s important to point out that this tutorial is an introduction to collections as a whole. In most of the following sections, you’ll find a blue alert box that’ll guide you to a dedicated article on the class or function at hand.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17af4333c509" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decorators in Python]]></title>
            <link>https://medium.com/@parthpritam7631/decorators-in-python-3d1979a6e5fc?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d1979a6e5fc</guid>
            <category><![CDATA[decorators]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Thu, 19 May 2022 09:36:42 GMT</pubDate>
            <atom:updated>2022-05-19T09:36:42.815Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*zfagfj4nlCXF5lN0xFsYXw.jpeg" /></figure><h3>Python Decorators</h3><p>A decorator takes in a function, adds some functionality and returns it. In this tutorial, you will learn how you can create a decorator and why you should use it.</p><h3>Prerequisites for learning decorators</h3><p>In order to understand about decorators, we must first know a few basic things in Python.</p><p>We must be comfortable with the fact that everything in Python (Yes! Even classes), are <a href="https://www.programiz.com/python-programming/class">objects</a>. Names that we define are simply identifiers bound to these objects. <a href="https://www.programiz.com/python-programming/function">Functions</a> are no exceptions, they are objects too (with attributes). Various different names can be bound to the same function object.</p><p>Here is an example.</p><pre>def first(msg):<br>    print(msg)<br><br><br>first(&quot;Hello&quot;)<br><br>second = first<br>second(&quot;Hello&quot;)</pre><p>Output :-</p><pre>Hello<br>Hello</pre><p>When you run the code, both functions first and second give the same output. Here, the names first and second refer to the same function object.</p><p>Now things start getting weirder.</p><p>Functions can be passed as arguments to another function.</p><p>If you have used functions like map, filter and reduce in Python, then you already know about this.</p><pre>def inc(x):<br>    return x + 1<br><br><br>def dec(x):<br>    return x - 1<br><br><br>def operate(func, x):<br>    result = func(x)<br>    return result</pre><p>Output</p><pre>&gt;&gt;&gt; operate(inc,3)<br>4<br>&gt;&gt;&gt; operate(dec,3)<br>2</pre><h3>Getting back to Decorators</h3><p>Functions and methods are called <strong>callable</strong> as they can be called.</p><p>In fact, any object which implements the special __call__() method is termed callable. So, in the most basic sense, a decorator is a callable that returns a callable.</p><p>Basically, a decorator takes in a function, adds some functionality and returns it.</p><h3>Decorating Functions with Parameters</h3><p>The above decorator was simple and it only worked with functions that did not have any parameters. What if we had functions that took in parameters like:</p><pre>def divide(a, b):<br>    return a/b</pre><p>This function has two parameters, a and b. We know it will give an error if we pass in b as 0.</p><pre>&gt;&gt;&gt; divide(2,5)<br>0.4<br>&gt;&gt;&gt; divide(2,0)<br>Traceback (most recent call last):<br>...<br>ZeroDivisionError: division by zero</pre><h3>Chaining Decorators in Python</h3><p>Multiple decorators can be chained in Python.</p><p>This is to say, a function can be decorated multiple times with different (or same) decorators. We simply place the decorators above the desired function.</p><pre>def star(func):<br>    def inner(*args, **kwargs):<br>        print(&quot;*&quot; * 30)<br>        func(*args, **kwargs)<br>        print(&quot;*&quot; * 30)<br>    return inner<br></pre><pre>def percent(func):<br>    def inner(*args, **kwargs):<br>        print(&quot;%&quot; * 30)<br>        func(*args, **kwargs)<br>        print(&quot;%&quot; * 30)<br>    return inner<br></pre><pre>@star<br>@percent<br>def printer(msg):<br>    print(msg)<br></pre><pre>printer(&quot;Hello&quot;)</pre><p><a href="https://www.programiz.com/python-programming/online-compiler">Run Code</a></p><p><strong>Output</strong></p><pre>******************************<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>Hello<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>******************************</pre><p>The above syntax of,</p><pre>@star<br>@percent<br>def printer(msg):<br>    print(msg)</pre><p>is equivalent to</p><pre>def printer(msg):<br>    print(msg)<br>printer = star(percent(printer))</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d1979a6e5fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exceptions in Python]]></title>
            <link>https://medium.com/@parthpritam7631/exceptions-in-python-7e5c0e8610a1?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e5c0e8610a1</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[exception-handling]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Thu, 19 May 2022 09:25:17 GMT</pubDate>
            <atom:updated>2022-05-19T09:25:17.427Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*zfagfj4nlCXF5lN0xFsYXw.jpeg" /></figure><h3>Exception</h3><p>An exception can be defined as an unusual condition in a program resulting in the interruption in the flow of the program.</p><p>Whenever an exception occurs, the program stops the execution, and thus the further code is not executed. Therefore, an exception is the run-time errors that are unable to handle to Python script. An exception is a Python object that represents an error</p><p>Python provides a way to handle the exception so that the code can be executed without any interruption. If we do not handle the exception, the interpreter doesn’t execute all the code that exists after the exception.</p><h3>Common Exceptions</h3><p>Python provides the number of built-in exceptions, but here we are describing the common standard exceptions. A list of common exceptions that can be thrown from a standard Python program is given below.</p><ol><li><strong>ZeroDivisionError:</strong> Occurs when a number is divided by zero.</li><li><strong>NameError:</strong> It occurs when a name is not found. It may be local or global.</li><li><strong>IndentationError:</strong> If incorrect indentation is given.</li><li><strong>IOError:</strong> It occurs when Input Output operation fails.</li><li><strong>EOFError:</strong> It occurs when the end of the file is reached, and yet operations are being performed.</li></ol><h3>Exception handling in python</h3><h3>The try-expect statement</h3><p>If the Python program contains suspicious code that may throw the exception, we must place that code in the <strong>try</strong> block. The <strong>try</strong> block must be followed with the <strong>except</strong>statement, which contains a block of code that will be executed if there is some exception in the try block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*VpRbL0OGJiFUav7GYAwWfw.jpeg" /></figure><h3>Raising exceptions</h3><p>An exception can be raised forcefully by using the <strong>raise</strong> clause in Python. It is useful in in that scenario where we need to raise an exception to stop the execution of the program.</p><p>For example, there is a program that requires 2GB memory for execution, and if the program tries to occupy 2GB of memory, then we can raise an exception to stop the execution of the program.</p><p>The syntax to use the raise statement is given below.</p><p><strong>Syntax</strong></p><ol><li><strong>raise</strong> Exception_class,&lt;value&gt;</li></ol><h3>Custom Exception</h3><p>The Python allows us to create our exceptions that can be raised from the program and caught using the except clause. However, we suggest you read this section after visiting the Python object and classes.</p><p>Consider the following example.</p><p><strong>Example</strong></p><p><strong>class</strong> ErrorInCode(Exception):</p><p><strong>def</strong> __init__(self, data):</p><p>self.data = data</p><p><strong>def</strong> __str__(self):</p><p><strong>return</strong> repr(self.data)</p><p><strong>try</strong>:</p><p><strong>raise</strong> ErrorInCode(2000)</p><p><strong>except </strong>ErrorInCode as ae:</p><p><strong>print</strong>(“Received error:”, ae.data)</p><p><strong>Output:</strong></p><p>Received error :2000</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e5c0e8610a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[POLYMORPHISM IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/polymorphism-in-python-2c08803a58aa?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c08803a58aa</guid>
            <category><![CDATA[polymorphism-python]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Thu, 19 May 2022 09:16:48 GMT</pubDate>
            <atom:updated>2022-05-19T09:16:48.286Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*zfagfj4nlCXF5lN0xFsYXw.jpeg" /></figure><h3>What is Polymorphism?</h3><p>The literal meaning of polymorphism is the condition of occurrence in different forms.</p><p>Polymorphism is a very important concept in programming. It refers to the use of a single type entity (method, operator or object) to represent different types in different scenarios.</p><h3>Polymorphism In Class methods</h3><p>Polymorphism with class methods is useful when we group different objects having the same method. we can add them to a list or a tuple, and we don’t need to check the object type before calling their methods. Instead, Python will check object type at runtime and call the correct method. Thus, we can call the methods without being concerned about which class type each object is. We assume that these methods exist in each class.</p><h3>Polymorphism in Built-in function len()</h3><p>The built-in function len() calculates the length of an object depending upon its type. If an object is a string, it returns the count of characters, and If an object is a <a href="https://pynative.com/python-lists/">list</a>, it returns the count of items in a list.</p><p>The len() method treats an object as per its class type.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c08803a58aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DATA TYPES IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/data-types-in-python-82b1381fa8b0?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/82b1381fa8b0</guid>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Fri, 13 May 2022 08:37:26 GMT</pubDate>
            <atom:updated>2022-05-13T08:37:26.995Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*zfagfj4nlCXF5lN0xFsYXw.jpeg" /></figure><p>In programming, data type is an important concept.Variables can store data of different types, and different types can do different things.</p><p>Text Type:str</p><p>Numeric Types:int, float, complex</p><p>Sequence Types:list, tuple, range</p><p>Mapping Type:dict</p><p>Set Types:set, frozenset</p><p>Boolean Type:bool</p><p>Binary Types:bytes, bytearray, memoryview</p><p>None Type:NoneType</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82b1381fa8b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OBJECT ORIENTED PROGRAMMING]]></title>
            <link>https://medium.com/@parthpritam7631/object-oriented-programming-20439568d6b8?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/20439568d6b8</guid>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[class]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Fri, 06 May 2022 16:43:03 GMT</pubDate>
            <atom:updated>2022-05-06T16:43:03.286Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>OBJECT ORIENTED PROGRAMMING</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*Vl5KyxsfL3GwXS5Qm-STuA.png" /></figure><p><strong>WHAT IS OBJECT-ORIENTED PROGRAMMING?</strong></p><p>Object-Oriented Programming(OOP), is all about creating “objects”. An object is a group of interrelated variables and functions. These variables are often referred to as properties of the object and functions are referred to as the behavior of the objects. These objects provide a better and clear structure for the program.</p><p>For example, a car can be an object. If we consider the car as an object then its properties would be — its color, its model, its price, its brand, etc. And its behavior/function would be acceleration, slowing down, gear change.</p><h3>PYTHON OOPs CONCEPT:-</h3><p>In this section, we will deep dive into the basic concepts of OOP. We will cover the following topics-</p><ol><li>Class</li><li>Object</li><li>Inheritance</li><li>Encapsulation</li><li>Polymorphism</li><li>Data Abstraction</li></ol><h3>1. What is a Class?</h3><p>A straight forward answer to this question is- A class is a collection of objects. Unlike the primitive data structures, classes are data structures that the user defines. They make the code more manageable.</p><p>2. <strong>WHAT IS OBJECTS?</strong></p><p>When we define a class only the description or a blueprint of the object is created. There is no memory allocation until we create its <strong>object</strong>. The <strong>objector</strong> <strong>instance</strong> contains real data or information.</p><h3>3. Inheritance in Python Class</h3><p>Inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as Parent class. And the class that inherits the properties from the parent class is the Child class.</p><h3>4. Encapsulation</h3><p>Encapsulation, as I mentioned in the initial part of the article, is a way to ensure security. Basically, it hides the data from the access of outsiders. Such as if an organization wants to protect an object/information from unwanted access by clients or any unauthorized person then encapsulation is the way to ensure this.</p><h3>5.Polymorphism</h3><p>This is a Greek word. If we break the term Polymorphism, we get “poly”-many and “morph”-forms. So Polymorphism means having many forms. In OOP it refers to the functions having the same names but carrying different functionalities.</p><h3>7. Data abstraction</h3><p>We use Abstraction for hiding the internal details or implementations of a function and showing its functionalities only. This is similar to the way you know how to drive a car without knowing the background mechanism.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20439568d6b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[USE OF BREAK, CONTINUE, PASS IN PYTHON]]></title>
            <link>https://medium.com/@parthpritam7631/use-of-break-continue-pass-in-python-e05563af4978?source=rss-9993b0799531------2</link>
            <guid isPermaLink="false">https://medium.com/p/e05563af4978</guid>
            <category><![CDATA[break]]></category>
            <category><![CDATA[pass]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Parthpritam]]></dc:creator>
            <pubDate>Wed, 04 May 2022 11:43:41 GMT</pubDate>
            <atom:updated>2022-05-04T11:43:41.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*zfagfj4nlCXF5lN0xFsYXw.jpeg" /></figure><p>Using loops in Python automates and repeats the tasks in an efficient manner. But sometimes, there may arise a condition where you want to exit the loop completely, skip an iteration or ignore that condition. These can be done by <strong>loop control statements</strong>. Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed. Python supports the following control statements.</p><ul><li><a href="https://www.geeksforgeeks.org/break-continue-and-pass-in-python/#break">Break statement</a></li><li><a href="https://www.geeksforgeeks.org/break-continue-and-pass-in-python/#continue">Continue statement</a></li><li><a href="https://www.geeksforgeeks.org/break-continue-and-pass-in-python/#pass">Pass statement</a></li></ul><h3>Break statement</h3><p>The break statement is used to terminate the loop or statement in which it is present. After that, the control will pass to the statements that are present after the break statement, if available. If the break statement is present in the nested loop, then it terminates only those loops which contains break statement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*XYJbBO-lkxtU6lvQMk15RA.jpeg" /></figure><h3>Continue statement</h3><p>Continue is also a loop control statement just like the break statement. continue statement is opposite to that of break statement, instead of terminating the loop, it forces to execute the next iteration of the loop.<br>As the name suggests the continue statement forces the loop to continue or execute the next iteration. When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and the next iteration of the loop will begin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*C3GIBVTtGsqiwzIL1Ts_bg.jpeg" /></figure><h3>Pass statement</h3><p>As the name suggests pass statement simply does nothing. The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. It is like null operation, as nothing will happen is it is executed. Pass statement can also be used for writing empty loops. Pass is also used for empty control statement, function and classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*otdQA0Dm9qHhYXOj6u3s4w.jpeg" /></figure><p><strong>Thanks you for going through this blog.</strong></p><p>PARTH PRITAM</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e05563af4978" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>