<?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 Sunainaa on Medium]]></title>
        <description><![CDATA[Stories by Sunainaa on Medium]]></description>
        <link>https://medium.com/@sunaina5310?source=rss-ed6529dcce79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MZ9an0N2jIRW33l6</url>
            <title>Stories by Sunainaa on Medium</title>
            <link>https://medium.com/@sunaina5310?source=rss-ed6529dcce79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:41:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sunaina5310/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[All About Super()…]]></title>
            <link>https://medium.com/@sunaina5310/all-about-super-85a3adc29c27?source=rss-ed6529dcce79------2</link>
            <guid isPermaLink="false">https://medium.com/p/85a3adc29c27</guid>
            <category><![CDATA[super]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sunainaa]]></dc:creator>
            <pubDate>Thu, 17 Sep 2020 14:56:30 GMT</pubDate>
            <atom:updated>2020-09-17T14:57:51.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*qqAZmuEm6fYsmlEhpzQ83Q.png" /></figure><p>Super method is used as a proxy for the object that delegates method calls to a parent or sibling class. This is useful for accessing inherited methods that have been overridden in a class. The super() function returns an object that represents the parent class.</p><h4><strong>super().methodName(args)</strong></h4><p>The super() method can also take two parameters:</p><p>1. Sub-class</p><p>2. An object that is an instance of that subclass.</p><p>There are two typical use cases for super:</p><p>a. In single inheritance, super can be used to refer to parent classes without naming them explicitly, thus making the code more maintainable. This use closely parallels the use of super in other programming languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icLKlB8V6vxMJk3rC32-YQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQnjR9-mDL_GwzbE8uJNEw.png" /></figure><p>b. In multiple inheritance, it supports cooperative dynamic execution environment. Good design dictates that this method have the same calling signature in every case (because the order of calls is determined at runtime, because that order adapts to changes in the class hierarchy, and because that order can include sibling classes that are unknown prior to runtime).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AH3L1P-HmqssNYa2cwZew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6PRQcDiduye-5zGSpUVog.png" /></figure><blockquote>To use the function properly, the following conditions must be met:</blockquote><blockquote>i) The method being called upon by super() must exist</blockquote><blockquote>ii) Both the caller and called functions need to have a matching argument signature</blockquote><blockquote>iii) Every occurrence of the method must include super() after you use it</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85a3adc29c27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming in Python]]></title>
            <link>https://medium.com/@sunaina5310/object-oriented-programming-in-python-2b1e37bb09f?source=rss-ed6529dcce79------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b1e37bb09f</guid>
            <category><![CDATA[inheritance-in-python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sunainaa]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 13:11:01 GMT</pubDate>
            <atom:updated>2020-08-25T14:50:05.982Z</atom:updated>
            <content:encoded><![CDATA[<h3>Object Oriented Programming in Python — Inheritance</h3><p>Python is a multi-paradigm programming language. It supports different programming approaches. One of the popular approaches to solve a programming problem is by creating objects. This is known as Object-Oriented Programming (OOP).</p><p>An object has two characteristics:</p><p>• attributes</p><p>• behavior</p><p>Let’s take an example:</p><p>A parrot is an object, as it has the following properties:</p><p>• name, age, color as attributes</p><p>• singing, dancing as behavior</p><p>The concept of OOP in Python focuses on creating reusable code. This concept is also known as DRY (Don’t Repeat Yourself).</p><p>In Python, the concept of OOP follows some basic principles</p><h3><strong>Class:</strong></h3><p>A class is a blueprint for the object.</p><p>We can think of class as a sketch of a parrot with labels. It contains all the details about the name, colors, size etc. Based on these descriptions, we can study about the parrot. Here, a parrot is an object.</p><p>The example for class of parrot can be:</p><p>class Parrot:</p><p>pass*</p><blockquote>*The <strong>pass</strong> statement is used as a placeholder for future code. When the <strong>pass</strong> statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed. Empty code is not allowed in loops, function definitions, class definitions, or in if statements.</blockquote><p>Here, we use the class keyword to define an empty class Parrot. From class, we construct instances. An instance is a specific object created from a class.</p><h3><strong>Objects:</strong></h3><p>An object (instance) is an instantiation of a class. When class is defined, only the description for the object is defined. Therefore, no memory or storage is allocated.</p><p>The example for object of parrot class can be:</p><p><strong>obj = Parrot()</strong></p><p>Here, obj is an object of class Parrot.</p><p>Suppose we have details of parrots. Now, we are going to show how to build the class and objects of parrots.</p><h4><strong>Example 1: Creating Class and Object in Python</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*SCV3EP4q3cg0x1cNxf_JRg.jpeg" /></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*85R2MZAG2beI0SrZSrJxeQ.jpeg" /></figure><blockquote>* class attribute belongs to the entire class rather than a specific object and is shared between all the objects of a class, and, is defined outside the constructor function {__init__(self,…….)}, of the class.</blockquote><blockquote>** instance attribute is a variable belonging to one and only one object.</blockquote><p>In the above program, we created a class with the name Parrot. Then, we define attributes. The attributes are a characteristic of an object.</p><p>These attributes are defined inside the __init__ method of the class. It is the initializer method that is first run as soon as the object is created.</p><p>Then, we create instances of the Parrot class. Here, jerry and pete are references (value) to our new objects.</p><p>We can access the class attribute using __class__.species. Class attributes are the same for all instances of a class. Similarly, we access the instance attributes using jerry.name and jerry.age. However, instance attributes are different for every instance of a class.</p><h3><strong>Methods:</strong></h3><p>Methods are functions defined inside the body of a class. They are used to define the behaviors of an object.</p><h4><strong>Example 2 : Creating Methods in Python</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*XGgCwhUW-y2t3ANVmk2-fg.jpeg" /></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Y9djQ-4-rlQcTr0pxK0UVQ.jpeg" /></figure><blockquote><strong>“__init__(self,….)</strong>” is a reserved method in python classes. It is known as a constructor in object oriented concepts. This method is called when an object is created from the class and it allow the class to initialize the attributes of a class.</blockquote><p>In the above program, we define two methods i.e sing() and dance(). These are called instance methods because they are called on an instance object i.e jerry.</p><h3><strong>Inheritance:</strong></h3><p>Inheritance is a way of creating a new class for using details of an existing class without modifying it. The newly formed class is a derived class (or child class). Similarly, the existing class is a base class (or parent class).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*fEXZDZSq0rRB3L9bA3zhoQ.jpeg" /></figure><h4><strong>Example 3: Use of Inheritance in Python</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1E3L-Z1xSBW143oVICaerA.jpeg" /></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/174/1*DfM1hoSwb1z-Si2BtaAhEQ.jpeg" /></figure><p>In the above program, we created two classes i.e. Bird (parent class) and Penguin (child class). The child class inherits the functions of parent class. We can see this from the swim() method.</p><p>Again, the child class modified the behavior of the parent class. We can see this from the whoisThis() method. Furthermore, we extend the functions of the parent class, by creating a new run() method.</p><p>Additionally, we use the super() function inside the __init__() method. This allows us to run the __init__() method of the parent class inside the child class.</p><h3><strong>Types Of Inheritance:</strong></h3><p>Depending upon the number of child and parent classes involved, there are four types of inheritance in python.</p><h4><strong>Single Inheritance:</strong></h4><p>When a child class inherits only a single parent class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*DBB2W7fTXBbG3-l4dZOd8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*vTRF8xtBJ2xiVwqQvCPZ_w.jpeg" /></figure><h3><strong>Multiple Inheritance:</strong></h3><p>When a child class inherits from more than one parent class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*SbQ918haLB4c8uCoNtP4jQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*tjYGZG0GMOjcYKVh2DzvhQ.jpeg" /></figure><h3><strong>Hierarchical Inheritance:</strong></h3><p>Hierarchical inheritance involves multiple inheritance from the same base or parent class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*w3rCKB2BwMsIBHiGThQjRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*-_-zNezbF15zYhTnkNUnUA.png" /></figure><h3><strong>Hybrid Inheritance:</strong></h3><p>Hybrid inheritance involves multiple inheritance taking place in a single program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*CfZe6OAd6EElivpI_qC1OA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*gSrxKUnpg86xS2H_sKzIqw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b1e37bb09f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>