<?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 Akhil Diddi on Medium]]></title>
        <description><![CDATA[Stories by Akhil Diddi on Medium]]></description>
        <link>https://medium.com/@akhilsubscriptions8?source=rss-8351947c2853------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4GIoEqsXNbY6mv9fAkLIsA.jpeg</url>
            <title>Stories by Akhil Diddi on Medium</title>
            <link>https://medium.com/@akhilsubscriptions8?source=rss-8351947c2853------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:20:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akhilsubscriptions8/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[Demystifying Data Structures in Python: Sets and Tuples]]></title>
            <link>https://medium.com/@akhilsubscriptions8/demystifying-data-structures-in-python-sets-and-tuples-f025826a0f57?source=rss-8351947c2853------2</link>
            <guid isPermaLink="false">https://medium.com/p/f025826a0f57</guid>
            <category><![CDATA[python-data-structures]]></category>
            <dc:creator><![CDATA[Akhil Diddi]]></dc:creator>
            <pubDate>Sat, 01 Jun 2024 10:30:45 GMT</pubDate>
            <atom:updated>2024-06-01T10:30:45.499Z</atom:updated>
            <content:encoded><![CDATA[<p>I taken class on Python Data Structures topics this is my first class that was great experience in this blog you will know what i taught</p><h4>Introduction</h4><p>Data structures are the fundamental building blocks of any programming language. They define how we organize and store data in our programs. Python provides a variety of built-in data structures, each with its strengths and use cases. In this blog post, we’ll delve into two fundamental data structures: sets and tuples.</p><h4>Sets</h4><ul><li><strong>Definition:</strong> A set is an unordered collection of unique elements. It’s like a bag that holds distinct items, without allowing duplicates.</li><li><strong>Key characteristics:</strong></li><li>Unordered: Elements in a set don’t maintain a specific order.</li><li>Unique elements: Sets don’t allow duplicate values.</li><li><strong>Operations on Sets:</strong></li><li>Creating sets: Use curly braces {} to create sets.</li><li>Adding elements: Use the add() method to add an element to a set.</li><li>Removing elements: Use the remove() method to remove a specific element, or discard() to remove an element if it exists (without raising an error).</li><li>Checking membership: Use the in operator to check if an element exists in a set.</li><li>Set operations: Python supports various set operations like union (|), intersection (&amp;), and difference (-) to combine sets.</li></ul><p><strong>Use cases:</strong></p><ul><li>Sets are ideal for storing unique elements like user IDs, removing duplicates from a list, and performing membership testing.</li></ul><p>Code Example:</p><pre>Python<br># Create a set of fruits<br>fruits = {&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;, &quot;banana&quot;}  # Duplicate &quot;banana&quot; will be removed<br><br># Add a new fruit<br>fruits.add(&quot;mango&quot;)<br><br># Check if an element exists<br>if &quot;apple&quot; in fruits:<br>    print(&quot;Apple is present in the set&quot;)<br><br># Print the set elements (order may vary)<br>print(fruits)</pre><p><strong>Tuples</strong></p><ul><li><strong>Definition:</strong> A tuple is an ordered, immutable collection of elements. It’s like a fixed-size list where you can’t change the elements after creation.</li><li><strong>Key characteristics:</strong></li><li>Ordered: Elements in a tuple maintain their insertion order.</li><li>Immutable: Tuples cannot be modified after creation.</li><li><strong>Creating tuples:</strong> Use parentheses () to create tuples.</li><li><strong>Accessing elements:</strong> Use indexing to access elements by position, similar to lists.</li><li><strong>Use cases:</strong></li><li>Tuples are useful for representing data that shouldn’t be changed, like coordinates or configuration settings. They are also used to return multiple values from functions.</li></ul><p><strong>Code Example:</strong></p><pre># Create a tuple of countries<br>countries = (&quot;India&quot;, &quot;USA&quot;, &quot;Canada&quot;)<br><br># Access the first element<br>first_country = countries[0]<br>print(first_country)  # Output: India<br><br># Tuples can contain elements of different data types<br>mixed_tuple = (10, &quot;hello&quot;, 3.14)<br><br># You cannot modify elements after creation (throws an error)<br># countries[0] = &quot;China&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f025826a0f57" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>