<?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 Nikhil Gupta on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Gupta on Medium]]></description>
        <link>https://medium.com/@nnikhilgupta1705?source=rss-93c538b98fd5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XgwgwqF_KzKIcrTA</url>
            <title>Stories by Nikhil Gupta on Medium</title>
            <link>https://medium.com/@nnikhilgupta1705?source=rss-93c538b98fd5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:26:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nnikhilgupta1705/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[Choosing the Right Python Data Structure: A Beginner’s Decision Guide]]></title>
            <link>https://medium.com/@nnikhilgupta1705/choosing-the-right-python-data-structure-a-beginners-decision-guide-f28f1c976398?source=rss-93c538b98fd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28f1c976398</guid>
            <category><![CDATA[user-friendly]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nikhil Gupta]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 05:44:37 GMT</pubDate>
            <atom:updated>2026-02-15T05:44:37.698Z</atom:updated>
            <content:encoded><![CDATA[<p>When you start learning Python, one of the most important skills is knowing <strong>which data structure to use</strong>. Python gives us powerful built-in structures like <strong>lists, tuples, sets, and dictionaries</strong>, but choosing the wrong one can make your program slower, harder to maintain, or more prone to bugs.</p><p>This beginner-friendly guide will help you understand:</p><ul><li>What each structure is used for</li><li>How they differ</li><li>When to use each one</li><li>Practical real-world scenarios</li><li>A clear comparison table</li></ul><p>Let’s simplify your decision-making process.</p><h3>1. Lists — When Order and Flexibility Matter</h3><h3>What is a List?</h3><p>A <strong>list</strong> is an ordered, mutable collection of items. This means:</p><ul><li>Order is preserved</li><li>You can modify elements</li><li>Duplicates are allowed</li></ul><h3>Example</h3><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;]<br>fruits.append(&quot;orange&quot;)</pre><pre>print(fruits)</pre><h3>Output:</h3><pre>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;orange&#39;]</pre><h3>When to Choose a List</h3><p>Use a list when:</p><ul><li>Order is important</li><li>You need indexing (list[0])</li><li>You need to modify data</li><li>Duplicates are allowed</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Student Marks List</strong></p><pre>marks = [80, 75, 90, 75]</pre><p>Here:</p><ul><li>Order matters (by exam sequence)</li><li>Duplicate marks are possible</li><li>You may update marks later</li></ul><h3>2. Tuples — When Data Should Not Change</h3><h3>What is a Tuple?</h3><p>A <strong>tuple</strong> is an ordered but immutable collection. Once created, it cannot be modified.</p><h3>Example</h3><pre>coordinates = (12.9716, 77.5946)<br>print(coordinates)</pre><h3>Output:</h3><pre>(12.9716, 77.5946)</pre><p>If you try to modify:</p><pre>coordinates[0] = 15</pre><p>You get:</p><pre>TypeError</pre><h3>When to Choose a Tuple</h3><p>Use a tuple when:</p><ul><li>Data should remain constant</li><li>You want safer, read-only values</li><li>You need dictionary keys</li><li>You want slightly better memory efficiency</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Fixed GPS Coordinates</strong></p><pre>office_location = (12.9716, 77.5946)</pre><p>Coordinates should not change accidentally.</p><h3>3. Sets — When You Need Unique Values</h3><h3>What is a Set?</h3><p>A <strong>set</strong> is an unordered collection of unique elements.</p><ul><li>No duplicates allowed</li><li>No guaranteed order</li><li>Very fast membership testing</li></ul><h3>Example</h3><pre>numbers = {1, 2, 3, 2}<br>print(numbers)</pre><h3>Output:</h3><pre>{1, 2, 3}</pre><p>Duplicate 2 is removed automatically.</p><h3>Fast Membership Check</h3><pre>users = {&quot;nikhil&quot;, &quot;rahul&quot;, &quot;anita&quot;}<br>print(&quot;nikhil&quot; in users)</pre><p>Output:</p><pre>True</pre><p>Sets are much faster than lists for checking membership in large datasets.</p><h3>When to Choose a Set</h3><p>Use a set when:</p><ul><li>You need unique values</li><li>You need fast lookup</li><li>You are performing mathematical operations</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Unique Website Visitors</strong></p><pre>visitors = {&quot;user1&quot;, &quot;user2&quot;, &quot;user1&quot;}</pre><p>Only unique visitors are stored.</p><h3>4. Dictionaries — When You Need Key-Value Mapping</h3><h3>What is a Dictionary?</h3><p>A <strong>dictionary</strong> stores data in key-value pairs.</p><pre>key → value</pre><ul><li>Keys must be unique</li><li>Very fast lookups</li><li>Maintains insertion order (Python 3.7+)</li></ul><h3>Example</h3><pre>student = {<br>    &quot;name&quot;: &quot;Nikhil&quot;,<br>    &quot;age&quot;: 21,<br>    &quot;grade&quot;: &quot;A&quot;<br>}</pre><pre>print(student[&quot;name&quot;])</pre><h3>Output:</h3><pre>Nikhil</pre><h3>When to Choose a Dictionary</h3><p>Use a dictionary when:</p><ul><li>You need to map one value to another</li><li>You want fast retrieval by key</li><li>Data has labels</li></ul><h3>Practical Use Case</h3><p>📌 <strong>User Profile in a Website</strong></p><pre>user = {<br>    &quot;username&quot;: &quot;nikhil123&quot;,<br>    &quot;email&quot;: &quot;abc@gmail.com&quot;,<br>    &quot;is_logged_in&quot;: True<br>}</pre><p>Each key represents meaningful labeled data.</p><h3>Quick Decision Guide</h3><p>Ask yourself these questions:</p><p>QuestionUseDo I need order and allow duplicates?ListShould the data never change?TupleDo I need only unique values?SetDo I need key-value mapping?Dictionary</p><h3>Complete Comparison Table</h3><p>FeatureListTupleSetDictionaryOrderedYesYesNoYes (3.7+)MutableYesNoYesYesAllows DuplicatesYesYesNoKeys: NoIndexingYesYesNoBy KeyFast LookupNo (O(n))No (O(n))Yes (O(1))Yes (O(1))Memory EfficientModerateHighModerateModerateBest ForOrdered dataFixed dataUnique valuesKey-value mapping</p><h3>Real-World Scenario: Online Shopping App</h3><p>Imagine building an online shopping app.</p><p>You might use:</p><h3>1️⃣ List — Product Display Order</h3><pre>products = [&quot;Shoes&quot;, &quot;Watch&quot;, &quot;Bag&quot;]</pre><p>Products appear in a specific order.</p><h3>2️⃣ Set — Unique Categories</h3><pre>categories = {&quot;Fashion&quot;, &quot;Electronics&quot;, &quot;Fashion&quot;}</pre><p>Duplicate categories are removed automatically.</p><h3>3️⃣ Dictionary — Product Details</h3><pre>product_details = {<br>    &quot;name&quot;: &quot;Shoes&quot;,<br>    &quot;price&quot;: 2999,<br>    &quot;stock&quot;: 50<br>}</pre><p>Quick access to product properties.</p><h3>4️⃣ Tuple — Immutable Discount Range</h3><pre>discount_range = (0, 50)</pre><p>Discount boundaries should not change accidentally.</p><h3>Why Choosing the Right Structure Matters</h3><h3>1. Performance</h3><p>If you use a list instead of a set for membership checking in 1 million records:</p><ul><li>List → Slow (O(n))</li><li>Set → Fast (O(1))</li></ul><h3>2. Memory Usage</h3><p>Tuples consume less memory than lists because they don’t allow resizing.</p><h3>3. Code Clarity</h3><p>Using a set clearly shows uniqueness is required:</p><pre>registered_emails = set()</pre><p>Better than:</p><pre>registered_emails = []</pre><h3>4. Data Safety</h3><p>Using tuples prevents accidental modification.</p><h3>Beginner Decision Flow</h3><p>Here’s a simple mental flow:</p><ol><li>Do I need labeled data? → Dictionary</li><li>Do I need uniqueness? → Set</li><li>Should data stay constant? → Tuple</li><li>Otherwise → List</li></ol><h3>Final Thoughts</h3><p>Python gives you powerful built-in data structures. The key to becoming a good developer is not just knowing how to use them — but knowing <strong>when</strong> to use them.</p><p>Choosing the right data structure improves:</p><ul><li>Speed</li><li>Memory efficiency</li><li>Code readability</li><li>Program reliability</li></ul><p>Whenever you start writing a program, pause and ask:</p><ul><li>Does order matter?</li><li>Should values be unique?</li><li>Will data change?</li><li>Do I need key-value mapping?</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28f1c976398" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Python Data Structure: A Beginner’s Decision Guide — Nikhil kaumr Gupta]]></title>
            <link>https://medium.com/@nnikhilgupta1705/choosing-the-right-python-data-structure-a-beginners-decision-guide-nikhil-kaumr-gupta-69d478664a2b?source=rss-93c538b98fd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/69d478664a2b</guid>
            <category><![CDATA[user-friendly]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Nikhil Gupta]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 05:39:23 GMT</pubDate>
            <atom:updated>2026-02-15T05:39:23.837Z</atom:updated>
            <content:encoded><![CDATA[<p>When you start learning Python, one of the most important skills is knowing <strong>which data structure to use</strong>. Python gives us powerful built-in structures like <strong>lists, tuples, sets, and dictionaries</strong>, but choosing the wrong one can make your program slower, harder to maintain, or more prone to bugs.</p><p>This beginner-friendly guide will help you understand:</p><ul><li>What each structure is used for</li><li>How they differ</li><li>When to use each one</li><li>Practical real-world scenarios</li><li>A clear comparison table</li></ul><p>Let’s simplify your decision-making process.</p><h3>1. Lists — When Order and Flexibility Matter</h3><h3>What is a List?</h3><p>A <strong>list</strong> is an ordered, mutable collection of items. This means:</p><ul><li>Order is preserved</li><li>You can modify elements</li><li>Duplicates are allowed</li></ul><h3>Example</h3><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;]<br>fruits.append(&quot;orange&quot;)</pre><pre>print(fruits)</pre><h3>Output:</h3><pre>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;orange&#39;]</pre><h3>When to Choose a List</h3><p>Use a list when:</p><ul><li>Order is important</li><li>You need indexing (list[0])</li><li>You need to modify data</li><li>Duplicates are allowed</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Student Marks List</strong></p><pre>marks = [80, 75, 90, 75]</pre><p>Here:</p><ul><li>Order matters (by exam sequence)</li><li>Duplicate marks are possible</li><li>You may update marks later</li></ul><h3>2. Tuples — When Data Should Not Change</h3><h3>What is a Tuple?</h3><p>A <strong>tuple</strong> is an ordered but immutable collection. Once created, it cannot be modified.</p><h3>Example</h3><pre>coordinates = (12.9716, 77.5946)<br>print(coordinates)</pre><h3>Output:</h3><pre>(12.9716, 77.5946)</pre><p>If you try to modify:</p><pre>coordinates[0] = 15</pre><p>You get:</p><pre>TypeError</pre><h3>When to Choose a Tuple</h3><p>Use a tuple when:</p><ul><li>Data should remain constant</li><li>You want safer, read-only values</li><li>You need dictionary keys</li><li>You want slightly better memory efficiency</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Fixed GPS Coordinates</strong></p><pre>office_location = (12.9716, 77.5946)</pre><p>Coordinates should not change accidentally.</p><h3>3. Sets — When You Need Unique Values</h3><h3>What is a Set?</h3><p>A <strong>set</strong> is an unordered collection of unique elements.</p><ul><li>No duplicates allowed</li><li>No guaranteed order</li><li>Very fast membership testing</li></ul><h3>Example</h3><pre>numbers = {1, 2, 3, 2}<br>print(numbers)</pre><h3>Output:</h3><pre>{1, 2, 3}</pre><p>Duplicate 2 is removed automatically.</p><h3>Fast Membership Check</h3><pre>users = {&quot;nikhil&quot;, &quot;rahul&quot;, &quot;anita&quot;}<br>print(&quot;nikhil&quot; in users)</pre><p>Output:</p><pre>True</pre><p>Sets are much faster than lists for checking membership in large datasets.</p><h3>When to Choose a Set</h3><p>Use a set when:</p><ul><li>You need unique values</li><li>You need fast lookup</li><li>You are performing mathematical operations</li></ul><h3>Practical Use Case</h3><p>📌 <strong>Unique Website Visitors</strong></p><pre>visitors = {&quot;user1&quot;, &quot;user2&quot;, &quot;user1&quot;}</pre><p>Only unique visitors are stored.</p><h3>4. Dictionaries — When You Need Key-Value Mapping</h3><h3>What is a Dictionary?</h3><p>A <strong>dictionary</strong> stores data in key-value pairs.</p><pre>key → value</pre><ul><li>Keys must be unique</li><li>Very fast lookups</li><li>Maintains insertion order (Python 3.7+)</li></ul><h3>Example</h3><pre>student = {<br>    &quot;name&quot;: &quot;Nikhil&quot;,<br>    &quot;age&quot;: 21,<br>    &quot;grade&quot;: &quot;A&quot;<br>}</pre><pre>print(student[&quot;name&quot;])</pre><h3>Output:</h3><pre>Nikhil</pre><h3>When to Choose a Dictionary</h3><p>Use a dictionary when:</p><ul><li>You need to map one value to another</li><li>You want fast retrieval by key</li><li>Data has labels</li></ul><h3>Practical Use Case</h3><p>📌 <strong>User Profile in a Website</strong></p><pre>user = {<br>    &quot;username&quot;: &quot;nikhil123&quot;,<br>    &quot;email&quot;: &quot;abc@gmail.com&quot;,<br>    &quot;is_logged_in&quot;: True<br>}</pre><p>Each key represents meaningful labeled data.</p><h3>Quick Decision Guide</h3><p>Ask yourself these questions:</p><p>QuestionUseDo I need order and allow duplicates?ListShould the data never change?TupleDo I need only unique values?SetDo I need key-value mapping?Dictionary</p><h3>Complete Comparison Table</h3><p>FeatureListTupleSetDictionaryOrderedYesYesNoYes (3.7+)MutableYesNoYesYesAllows DuplicatesYesYesNoKeys: NoIndexingYesYesNoBy KeyFast LookupNo (O(n))No (O(n))Yes (O(1))Yes (O(1))Memory EfficientModerateHighModerateModerateBest ForOrdered dataFixed dataUnique valuesKey-value mapping</p><h3>Real-World Scenario: Online Shopping App</h3><p>Imagine building an online shopping app.</p><p>You might use:</p><h3>1️⃣ List — Product Display Order</h3><pre>products = [&quot;Shoes&quot;, &quot;Watch&quot;, &quot;Bag&quot;]</pre><p>Products appear in a specific order.</p><h3>2️⃣ Set — Unique Categories</h3><pre>categories = {&quot;Fashion&quot;, &quot;Electronics&quot;, &quot;Fashion&quot;}</pre><p>Duplicate categories are removed automatically.</p><h3>3️⃣ Dictionary — Product Details</h3><pre>product_details = {<br>    &quot;name&quot;: &quot;Shoes&quot;,<br>    &quot;price&quot;: 2999,<br>    &quot;stock&quot;: 50<br>}</pre><p>Quick access to product properties.</p><h3>4️⃣ Tuple — Immutable Discount Range</h3><pre>discount_range = (0, 50)</pre><p>Discount boundaries should not change accidentally.</p><h3>Why Choosing the Right Structure Matters</h3><h3>1. Performance</h3><p>If you use a list instead of a set for membership checking in 1 million records:</p><ul><li>List → Slow (O(n))</li><li>Set → Fast (O(1))</li></ul><h3>2. Memory Usage</h3><p>Tuples consume less memory than lists because they don’t allow resizing.</p><h3>3. Code Clarity</h3><p>Using a set clearly shows uniqueness is required:</p><pre>registered_emails = set()</pre><p>Better than:</p><pre>registered_emails = []</pre><h3>4. Data Safety</h3><p>Using tuples prevents accidental modification.</p><h3>Beginner Decision Flow</h3><p>Here’s a simple mental flow:</p><ol><li>Do I need labeled data? → Dictionary</li><li>Do I need uniqueness? → Set</li><li>Should data stay constant? → Tuple</li><li>Otherwise → List</li></ol><h3>Final Thoughts</h3><p>Python gives you powerful built-in data structures. The key to becoming a good developer is not just knowing how to use them — but knowing <strong>when</strong> to use them.</p><p>Choosing the right data structure improves:</p><ul><li>Speed</li><li>Memory efficiency</li><li>Code readability</li><li>Program reliability</li></ul><p>Whenever you start writing a program, pause and ask:</p><ul><li>Does order matter?</li><li>Should values be unique?</li><li>Will data change?</li><li>Do I need key-value mapping?</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69d478664a2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>