<?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 Neesha Basnet on Medium]]></title>
        <description><![CDATA[Stories by Neesha Basnet on Medium]]></description>
        <link>https://medium.com/@neeshaa?source=rss-8d1625d4644d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HNv3CA7TXmUgHm2I</url>
            <title>Stories by Neesha Basnet on Medium</title>
            <link>https://medium.com/@neeshaa?source=rss-8d1625d4644d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:21:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neeshaa/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[Getting Started with FastAPI: Why It’s Popular and What I Built with It as a Beginner]]></title>
            <link>https://medium.com/intern-elite/getting-started-with-fastapi-why-its-popular-and-what-i-built-with-it-as-a-beginner-78cf5ad96bc4?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/78cf5ad96bc4</guid>
            <category><![CDATA[fastapi-pydantic]]></category>
            <category><![CDATA[fastapi]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 14:41:39 GMT</pubDate>
            <atom:updated>2025-07-09T14:58:57.902Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is FastAPI?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tsluG30zghddLue3" /></figure><p>In the ever-growing landscape of Python web frameworks, FastAPI has emerged as a standout tool for building modern, high-performance APIs. Released by Sebastián Ramírez in 2018, FastAPI is a relatively young framework that has quickly gained popularity among developers for its:</p><ul><li>Speed</li><li>Ease of use</li><li>Built-in data validation</li><li>Automatic documentation generation</li></ul><p>Built on top of Starlette (for the web parts) and Pydantic (for data validation), FastAPI is designed to help developers build RESTful APIs quickly and reliably.</p><h3><strong>Why Is FastAPI So Popular?</strong></h3><p>FastAPI has grown rapidly in the Python community, and here’s why:</p><p>✅ Type Hinting + Validation<br> → FastAPI uses Python’s type hints to validate and serialize data automatically using Pydantic.</p><p>⚡ Super Fast<br> → It’s one of the fastest Python frameworks, thanks to Starlette’s async capabilities. It’s often comparable in performance to Node.js and Go.</p><p>📃 Auto-generated Docs<br>Every FastAPI app comes with:</p><ul><li>Swagger UI at /docs</li><li>ReDoc at /redoc</li></ul><p>This means our API is documented the moment we write our endpoints.</p><p>🧠 Developer Experience<br>Features like editor autocomplete, clear error messages, and easy debugging make it ideal for beginners and professionals alike.</p><h3>Where Is FastAPI Used?</h3><p>FastAPI is used in many real-world applications, especially where performance, API reliability, and data validation matter.</p><p><strong>Key Use Cases:</strong><br> — Machine learning model deployment (e.g., serving models from scikit-learn, PyTorch, or TensorFlow)</p><p>— Microservices architecture</p><p>— Internal APIs for web/mobile apps</p><p>— Async-heavy apps (e.g., handling external APIs or databases)</p><p>Companies like Netflix, Uber, Microsoft, and Reddit have adopted FastAPI in various parts of their stack.</p><h3>My First FastAPI Project: A Simple Todo API</h3><p>As someone just starting out with FastAPI, I followed a beginner tutorial to build a small project — a Todo CRUD API using FastAPI and Pydantic.</p><p>Here’s a quick breakdown of what I built:</p><p>📁 Project Structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*YB8mOpHijcUrJEBnb5eCFQ.png" /><figcaption>Project Structure</figcaption></figure><p><strong>What the API Can Do:</strong><br> → GET /todos — fetch all todos</p><p>→ GET /todos/{id} — fetch a single todo</p><p>→ POST /todos — create a new todo</p><p>→ PUT /todos/{id} — update an existing todo</p><p>→ DELETE /todos/{id} — delete a todo</p><ul><li><strong>Sample Pydantic Model (models.py)</strong></li></ul><pre>from pydantic import BaseModel<br><br>class Todo(BaseModel):<br>    id: int<br>    item: str</pre><ul><li><strong>Sample FastAPI App (main.py)</strong></li></ul><pre>from fastapi import FastAPI<br>from models import Todo<br><br>app = FastAPI()<br><br><br>@app.get(&quot;/&quot;)<br>async def root():<br>    return {&quot;message&quot;: &quot;Hello World&quot;}<br><br>todos= []<br><br># Get all todos<br>@app.get(&quot;/todos&quot;)<br>async def get_todos():<br>    return {&quot;todos&quot;: todos}<br><br>#Get single todo<br>@app.get(&quot;/todos/{todo_id}&quot;)<br>async def get_todo(todo_id: int):<br>    for todo in todos:<br>        if todo.id == todo_id:<br>            return {&quot;todo&quot;: todo}<br>    return {&quot;message&quot;: &quot;no todos found&quot;}<br><br>#Create a todo<br>@app.post(&quot;/todos&quot;)<br>async def create_todos(todo: Todo):<br>    todos.append(todo)<br>    return {&quot;message&quot;: &quot;Todo has been added&quot;}<br><br>#Update a todo<br>@app.put(&quot;/todos/{todo_id}&quot;)<br>async def update_todo(todo_id: int, todo_obj:Todo):<br>    for todo in todos:<br>        if todo.id == todo_id:<br>            todo.id= todo_id<br>            todo.item = todo_obj.item<br>            return {&quot;todo&quot;: todo}<br>    return {&quot;message&quot;: &quot;no todos found to update&quot;}<br><br>#Delete a todo<br>@app.delete(&quot;/todos/{todo_id}&quot;)<br>async def delete_todo(todo_id: int):<br>    for todo in todos:<br>        if todo.id == todo_id:<br>            todos.remove(todo)<br>            return {&quot;message&quot;: &quot; has been deleted&quot;}<br>    return {&quot;message&quot;: &quot;no todos found&quot;}</pre><p>Running a FastAPI app with uvicorn main:app --reload</p><p>Accessing through Swagger UI: <a href="http://localhost:8000/docs">http://localhost:8000/docs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VRk49WOoZZ9RE8Ss2NnJow.png" /><figcaption><strong>Interactive API docs</strong></figcaption></figure><h3><strong>What I Learned</strong></h3><ul><li>How to build and structure a FastAPI project</li><li>How to define models using Pydantic</li><li>How CRUD operations work in an API</li><li>How powerful automatic documentation can be.</li></ul><h3>My Final Thoughts</h3><p>FastAPI offers a perfect mix of power and simplicity, making it a great choice for both beginners and professionals. As a Python developer, learning FastAPI opened up a whole new world of web development for me.</p><p>If you’re coming from Flask or Django, or just starting out, I highly recommend giving FastAPI a try — you’ll be surprised at how quickly you can build something useful.</p><p><strong>Thank you for reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78cf5ad96bc4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/getting-started-with-fastapi-why-its-popular-and-what-i-built-with-it-as-a-beginner-78cf5ad96bc4">Getting Started with FastAPI: Why It’s Popular and What I Built with It as a Beginner</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Project with n8n: Creating and Emailing a JSON File]]></title>
            <link>https://medium.com/intern-elite/my-first-project-with-n8n-creating-and-emailing-a-json-file-124f665ff00e?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/124f665ff00e</guid>
            <category><![CDATA[n8n-workflow]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Fri, 20 Jun 2025 15:58:26 GMT</pubDate>
            <atom:updated>2025-06-21T10:03:08.768Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently came across n8n, an open-source automation tool, and decided to try it out for a small project. I was surprised by how easy it was to connect different apps and services without writing much code. In this post, I’ll share what I learned, how n8n works, and walk you through the project I built using it.</p><p><strong>What is n8n?</strong></p><p>→ n8n is an automation tool that lets us create custom workflows. Think of it as a digital assistant that handles repetitive work for you by scheduling tasks, leveraging n8n integrations to connect disparate systems, or automatically moving data between different apps that don’t normally communicate with each other out of the box.</p><p><strong>Key Concepts in n8n</strong><br> → Workflows: A series of connected tasks (called nodes) that execute one after another.</p><p>→ Nodes: These are the building blocks — like blocks in a flowchart.</p><p>→ Trigger Node: Starts the workflow (e.g., when a webhook is received)</p><p>→ Regular Nodes: Perform actions (e.g., send an email, fetch data)</p><p>→ Data Flow: Data moves from one node to another, and you can manipulate or transform it as it goes.</p><p><strong>Why n8n?</strong></p><ul><li>Open-source and visual</li><li>No-code/low-code but powerful</li><li>Can run on your machine (desktop/self-hosted)</li><li>Doesn’t lock you into a platform</li></ul><p><strong>I built a small but complete workflow</strong>:<br>- **Trigger**: Manually start the workflow<br>- **Create**: Add fake user data (name, email, phone)<br>- **Save**: Convert that data into a `.json` file and save it locally<br>- **Send**: Email that `.json` file to myself as an attachment</p><p><strong>How I Built It — Step by Step</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73dfdwtYnDm4zzTb5gA4EQ.png" /></figure><ul><li><strong>Step 1</strong>: Manual Trigger</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*txVDHqZ9SjG-x10ErgkvXA.png" /></figure><p>Function: Starts the workflow manually with a button click.</p><p>Why it’s used: This is perfect for testing or small flows where you want to control when the workflow runs (instead of waiting for a schedule or external event).</p><ul><li><strong>Step 2</strong>: Edit Fields (Set Node)</li></ul><p>Function: Adds custom data to the workflow manually — like a name, email, and phone number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*7caHbj23LY4sOmQ0iiqjTg.png" /></figure><p>Then, I added a “Set” node to define fake user data:</p><p>-Name: Triveni Basnet<br>- Email: tri123<a href="/service/mailto:bneesha7@gmail.com">@gmail.com</a><br>- Phone: +977–9800000000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRf0kLo2HC7rGlQPbRVU7g.png" /></figure><ul><li><strong>Step 3</strong>: Convert Data to File (Move Binary Data)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*3xyv4ZXvjuCQo-4ujBrr_g.png" /></figure><p>This part took me a while to understand :</p><p>In the latest version of n8n, there’s a node that lets us **convert your JSON into a binary file** (so we can save or send it).</p><p>I used the “Move Binary Data” node, with:<br>- Action: `Convert to JSON`<br>- File Name: `fake-user.json`<br>- MIME Type: `application/json`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vEDqV84fAG_EDafcDXl6Gg.png" /></figure><ul><li><strong>Step 4</strong>: Write to Disk</li></ul><p>Function: Converts the JSON data (from the “Edit Fields” node) into a binary file format that can be saved or sent as an attachment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*mT6K1WxdOXIpbmzOgx89wQ.png" /></figure><p>Then I used the “Read/Write Files from Disk” node to save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKLa5DT_jFZ7gO86ukWmWg.png" /></figure><p>I set the operation to:<br>- Write File To Disk<br>- File path: `fake-user.json`<br>- Binary property: `data`</p><p>And it wrote the file.</p><ul><li><strong>Step 5</strong>: Email the File</li></ul><p>Function: Sends an email with the .json file attached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*ROJmztREWgtx6-7QMNCx9g.png" /></figure><p>Authentication: OAuth2</p><p>I connected my Gmail account securely using the built-in OAuth2 option in n8n</p><p>Email settings:</p><p>To: my own email address</p><p>Subject: Fake User JSON File</p><p>Message: A short message like “Hi there, Please find the attached fake user data file. Regards, Neesha”</p><p>Attachments: I selected the binary property data (from the previous file node)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B0PO_n0_Jao9zMHKMcKmOA.png" /></figure><p>Now, finally I created a workflow that works manually. And it send email to my given email address as soon as I execute workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tu1U9J2IFagt2Ot83JDjZg.png" /></figure><p>This small project taught me how to build something real step by step without writing code. I created data, turned it into a file, and emailed it all using visual blocks. That’s powerful!</p><p>If you’re new to automation tools like n8n, my advice is:<br> Start small. Be patient. And don’t give up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=124f665ff00e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/my-first-project-with-n8n-creating-and-emailing-a-json-file-124f665ff00e">My First Project with n8n: Creating and Emailing a JSON File</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Inheritance in Python]]></title>
            <link>https://medium.com/intern-elite/understanding-inheritance-in-python-e6e1c4aa528f?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6e1c4aa528f</guid>
            <category><![CDATA[python-inheritance]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 11:09:04 GMT</pubDate>
            <atom:updated>2025-06-11T14:18:18.105Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is known for its clean syntax and powerful object-oriented programming (OOP) capabilities. One of the core pillars of OOP is inheritance, a concept that allows you to build new classes based on existing ones.</p><ol><li><strong>What is Inheritance?</strong></li></ol><p>Inheritance allows one class (called the child or subclass) to inherit the properties and behaviors (methods and attributes) of another class (called the parent or superclass).</p><p>This makes it easier to reuse code and build a more hierarchical structure in our application.</p><p><strong>2. Why Use Inheritance?<br></strong>Imagine we’re building a game with different types of characters — like a Warrior, a Mage, and a Healer. All of them have some shared features like name, health, and attack().</p><p>Rather than defining these features separately in every class, we can define them once in a base class (Character) and then have the other classes inherit from it.</p><p><strong>Syntax of Inheritance</strong></p><p>Example:</p><pre>class Animal:<br>    def __init__(self, name):<br>        self.name = name<br><br>    def speak(self):<br>        return f&quot;{self.name} makes a sound.&quot;<br><br>class Dog(Animal):<br>    def speak(self):<br>        return f&quot;{self.name} barks.&quot;<br><br>class Cat(Animal):<br>    def speak(self):<br>        return f&quot;{self.name} meows.&quot;</pre><p>Note:</p><ul><li>Dog and Cat inherit from Animal.</li><li>They override the speak() method with their own implementation.</li></ul><p><strong>* Using super() to Access the Parent</strong><br>Sometimes, you’ll want to use methods from the parent class within the child class. That’s where super() comes in handy.</p><pre>class Bird(Animal):<br>    def speak(self):<br>        parent_sound = super().speak()<br>        return f&quot;{parent_sound} But specifically, {self.name} chirps.&quot;</pre><p><strong>Types of Inheritance in Python</strong><br>Python supports several types of inheritance:</p><ul><li>Single Inheritance — One child class inherits from one parent class.</li><li>Multiple Inheritance — A child class inherits from more than one parent class.</li><li>Multilevel Inheritance — A child class inherits from a class that itself inherited from another class.</li><li>Hierarchical Inheritance — Multiple child classes inherit from the same parent class.</li></ul><p>Here’s an example of multiple inheritance:</p><pre>class Flyer:<br>    def fly(self):<br>        return &quot;Flying high&quot;<br><br>class Swimmer:<br>    def swim(self):<br>        return &quot;Swimming fast&quot;<br><br>class Duck(Flyer, Swimmer):<br>    pass<br><br>d = Duck()<br>print(d.fly())   # Output: Flying high<br>print(d.swim())  # Output: Swimming fast</pre><p>Inheritance is a powerful tool in Python, helping us write cleaner, DRY (Don’t Repeat Yourself), and more organized code. Understanding how and when to use it will level up your programming game, especially when dealing with large, complex systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6e1c4aa528f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/understanding-inheritance-in-python-e6e1c4aa528f">Understanding Inheritance in Python</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Python Exception Handling, Custom Handling and Access Control]]></title>
            <link>https://medium.com/intern-elite/understanding-python-exception-handling-custom-handling-and-access-control-fef731f14b4b?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fef731f14b4b</guid>
            <category><![CDATA[access-modifier]]></category>
            <category><![CDATA[custom-exception-handling]]></category>
            <category><![CDATA[python-exception]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 17:02:29 GMT</pubDate>
            <atom:updated>2025-06-06T01:24:04.444Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether you’re writing robust scripts or building scalable apps, knowing how to handle errors and control access in Python is essential for clean and maintainable code. Let’s dive into exception handling, custom exceptions, and Python’s take on access modifiers.</p><p>In this article, we’ll explore:</p><ul><li>What exception handling.</li><li>How to create your own custom exceptions</li><li>What public, protected and private mean in Python.</li></ul><ol><li><strong>Why Python Exception Handling matters?<br></strong>In Python, exceptions are errors detected during execution. Exception handling ensures a program doesn’t crash unexpectedly and can handle errors gracefully.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mmHpKB1zBhfFRS17.png" /></figure><ul><li><strong>Try-except</strong></li></ul><p>Here is a basic example of exception handling.</p><pre>try:<br>    ## code block where exception can occur<br>    a = 1<br>    b=&#39;n&#39;<br>    c=a+b<br>except NameError as ex1:<br>    print(&quot;the user have not defined the variable&quot;)<br><br>except TypeError as ex2:<br>    print(&quot;use similar datatype&quot;)<br><br>except Exception as ex:<br>    print(ex)<br><br># output : use similar datatype</pre><p>try: Python tries to run this block.</p><p>except: If it encounters a Error, it runs this instead.</p><ul><li><strong>Try-Except-Else-Finally</strong></li></ul><pre>## try else and finally<br>try:<br>    a = int(input(&quot;Enter the number 1&quot;))<br>    b=int(input( &#39;enter number 2&#39;))<br>    c=a/b<br>    <br>except NameError as ex1:<br>    print(&quot;the user have not defined the variable&quot;)<br><br>except ZeroDivisionError as ex3:<br>    print(&quot;please provide number greater that 0&quot;)<br><br>except TypeError as ex2:<br>    print(&quot;use similar datatype&quot;)<br><br>except Exception as ex:<br>    print(ex)<br><br>else:<br>    print(c)<br>    <br>finally:<br>    print(&quot;exceution is done&quot;)<br><br># output:  please provide number greater that 0<br>            exceution is done</pre><p>Use else for code that should run only if no exception occurred.</p><p>Use finally for cleanup actions like closing files or disconnecting from databases.</p><p><strong>2. Custom Exception Handling</strong></p><p>Built-in exceptions are great, but sometimes we need to define our own, especially in bigger projects. They make our code easier to read, debug, and maintain, especially when our app grows.</p><p>Here is an example:</p><pre>class dobException(Error):<br>    pass<br><br>year = int(input(&#39;enter the year of birth : &#39;))<br>age = 2025- year<br><br>try:<br>    if age&lt;= 30 &amp; age&gt;20:<br>        print(&quot;age is valid&quot;)<br>    else:<br>        raise dobException<br>except dobException:<br>    print(&quot;the year age is not valid&quot;)<br><br># output: enter the year of birth : 2003<br>           age is valid</pre><p>Another example:</p><pre>class NegativeNumberError(Exception):<br>    def __init__(self, value):<br>        self.value = value<br>        super().__init__(f&quot;Negative number provided: {value}&quot;)<br><br>def square_root(x):<br>    if x &lt; 0:<br>        raise NegativeNumberError(x)<br>    return x ** 0.5<br><br>try:<br>    result = square_root(-4)<br>    print(result)<br>except NegativeNumberError as e:<br>    print(e)<br><br># output: Negative number provided: -4</pre><p><strong>3. Public, Protected, and Private in Python</strong></p><p>Python doesn’t have strict access modifiers like other languages (e.g., Java or C++), but it uses naming conventions to indicate how attributes and methods should be treated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*xh5nkjNfECK8T5nG.png" /></figure><p>A. public members</p><ul><li>No underscore.</li><li>These are accessible from anywhere.</li></ul><pre>class Dog:<br>    def __init__(self):<br>        self.name = &quot;Buddy&quot;  # Public<br><br>dog = Dog()<br>print(dog.name)  </pre><p>B. protected Members<br>Prefix with a single underscore (_). It signals: “Hey, this is internal. Be careful.”</p><pre>class Dog:<br>    def __init__(self):<br>        self._mood = &quot;Happy&quot;  # Protected<br><br>dog = Dog()<br>print(dog._mood)  # Works, but shouldn&#39;t be accessed directly</pre><p>C. private Members<br>Prefix with two underscores (__). This triggers name mangling.</p><pre>class Car():<br>    def __init__(self, windows, doors, enginetype):<br>        self.__windows=windows<br>        self.__doors= doors<br>        self.__enginetype= enginetype</pre><p>Today, I learned how to make my Python programs smarter and safer by:</p><ul><li>Handling errors with try, except, else and finally.</li><li>Creating my own custom exceptions for better control</li><li>Understanding how public, protected, and private members work in Python</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fef731f14b4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/understanding-python-exception-handling-custom-handling-and-access-control-fef731f14b4b">Understanding Python Exception Handling, Custom Handling and Access Control</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python OOP : A Beginner’s Guide to Classes and Objects]]></title>
            <link>https://medium.com/intern-elite/python-oop-a-beginners-guide-to-classes-and-objects-8272ee079210?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8272ee079210</guid>
            <category><![CDATA[oop-in-python]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 17:41:05 GMT</pubDate>
            <atom:updated>2025-06-06T01:22:27.551Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python OOP : A Beginner’s Guide to Classes and Objects</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*lGnsZ8VeJurJ5_fl4Qzddw.png" /><figcaption>fig: OOP concepts in Python</figcaption></figure><p>Have you ever wondered how Python models real-world things like animals, cars, or bank accounts? That’s where Object-Oriented Programming (OOP) comes in.</p><p>Whether we’re building a small script or designing large applications, understanding OOP will make our code more organized, reusable, and easier to maintain.</p><p>We’ll learn how to use Python’s OOP features like:</p><ul><li>Classes</li><li>Objects</li><li>Instance vs Class Variables</li><li>Methods (instance, class, and static)</li><li>Inheritance</li><li>Encapsulation</li></ul><p><strong>What is OOP?</strong><br>Object-Oriented Programming (OOP) is a programming paradigm based on the concept of “objects” which can contain data (attributes) and code (methods).</p><ol><li><strong>Python Classes and Objects</strong><br>A class is a blueprint for creating objects. An object is an instance of that class.</li></ol><pre>class Student:<br>    def __init__(self, name, age):<br>        self.name = name<br>        self.age = age<br><br>student1 = Student(&quot;Neesha&quot;, 22)<br>print(student1.name)<br><br>  # Output: Neesha</pre><p>2.<strong> Instance vs Class Variables</strong></p><ul><li>Instance variables are unique to each other.</li><li>Class Variables are shared across all instances.</li></ul><pre>class Student:<br>    Faculty = &quot;Science and Technology&quot;  # class variable<br><br>    def __init__(self, name):<br>        self.name = name  # instance variable<br><br>student1 = Student(&quot;Ram&quot;)<br>student2 = Student(&quot;Sita&quot;)<br><br>print(student1.Faculty)  # Science and Technology<br>print(student2.name)     # Sita</pre><p>3. <strong>Python Methods: Instance, Class, Static</strong><br>A. Instance Method<br> It helps to accesses or modifies object state.</p><pre>class Dog:<br>    def __init__(self, name):<br>        self.name = name<br><br>    def speak(self, sound):<br>        return f&quot;{self.name} says {sound}&quot;<br><br>dog = Dog(&quot;Doggy&quot;)<br>print(dog.speak(&quot;Woof!&quot;))  # Doggy says Woof!</pre><p>B. Class Method<br>It works with the class itself, not individual objects.</p><pre>class Dog:<br>    species = &quot;indie&quot;<br><br>    @classmethod<br>    def info(cls):<br>        return f&quot;Species: {cls.species}&quot;<br><br>print(Dog.info())  # Species: indie</pre><p>C. Static Method<br>It doesn’t access class or instance data. Used for utility functions.</p><pre>class Math:<br>    @staticmethod<br>    def add(a, b):<br>        return a + b<br><br>print(Math.add(5, 3))  # 8</pre><p>4.<strong> Inheritance in Python</strong></p><p>Inheritance allows you to create a new class (child) from an existing one (parent).</p><pre>class Animal:<br>    def __init__(self, name):<br>        self.name = name<br><br>    def speak(self):<br>        return &quot;Some sound&quot;<br><br>class Dog(Animal):<br>    def speak(self):<br>        return f&quot;{self.name} says Woof!&quot;<br><br>dog = Dog(&quot;Charlie&quot;)<br>print(dog.speak())  # Charlie says Woof!</pre><p>5. Encapsulation: Protecting Data<br>Encapsulation is the practice of hiding the internal state of an object and only allowing access to it through public methods.</p><p>This helps:</p><ul><li>Prevent direct access to sensitive data</li><li>Protect the internal logic from outside interference</li><li>Provide controlled interaction (via “getters” and “setters”)</li></ul><pre>class Account:<br>    def __init__(self, owner, balance):<br>        self.owner = owner<br>        self.__balance = balance  # private<br><br>    def get_balance(self):<br>        return self.__balance<br><br>acc = Account(&quot;Alice&quot;, 1000)<br>print(acc.get_balance())  <br># 1000</pre><p><strong>Final Thoughts</strong><br>Here’s what we covered:</p><p>Class = blueprint</p><p>Object = real instance</p><p>Instance Variables = specific to object</p><p>Class Variables = shared across all objects</p><p>Instance Methods = work with object</p><p>Class &amp; Static Methods = broader scope</p><p>Inheritance &amp; Encapsulation = code reuse and protection</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8272ee079210" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/python-oop-a-beginners-guide-to-classes-and-objects-8272ee079210">Python OOP : A Beginner’s Guide to Classes and Objects</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: List Comprehensions, String Formatting, and Iterators]]></title>
            <link>https://medium.com/intern-elite/mastering-python-list-comprehensions-string-formatting-and-iterators-315dc7729e3d?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/315dc7729e3d</guid>
            <category><![CDATA[python-list-comprehension]]></category>
            <category><![CDATA[python-string-format]]></category>
            <category><![CDATA[python-iterator]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 17:55:37 GMT</pubDate>
            <atom:updated>2025-06-02T10:38:53.075Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether we’re a beginner or brushing up on Python fundamentals, understanding list comprehensions, string formatting, and the iterator protocol is essential for writing clean, efficient, and Pythonic code.</p><p>In this post, we’ll go deep into each concept — with examples and explanations — to help you use them like a pro.</p><ol><li><strong>What is a List Comprehension?</strong><br> →A list comprehension is a concise way to generate a new list by applying an expression to each item in an iterable. It’s often more readable and efficient than a for loop.</li></ol><p>Its syntax:</p><pre>[expression for item in iterable if condition]</pre><p>Some examples are given below:</p><pre>lst=[1,2,3,4,5]<br>[i*i for i in lst]<br><br>#output : [1, 4, 9, 16, 25]</pre><pre>evens = [x for x in range(10) if x % 2 == 0]<br># Output: [0, 2, 4, 6, 8]</pre><p><strong>Advantages:</strong></p><p>a. Cleaner, faster syntax.<br> b. Avoid when logic becomes too complex (for readability).</p><p><strong>2. String Formatting in Python</strong></p><p>String formatting in Python allows us to create dynamic strings by inserting values into placeholders. The .format() method uses curly braces {}as placeholders that are replaced by the corresponding values passed to the method.</p><p>Here are some simple examples:</p><pre>&quot;Hello, {}!&quot;.format(&quot;Neesha&quot;)<br><br># Output: &quot;Hello, Neesha!&quot;</pre><pre>def welcome_email(firstname, lastname):<br>    return &#39;welcome {}. everyone please welcome {}&#39;. format(firstname, lastname)<br><br>welcome_email(&#39;Neesha&#39;, &#39;Basnet&#39;)<br><br># output: &#39;welcome Neesha. everyone please welcome Basnet&#39;</pre><p>Ordering is important while formating.</p><pre>def welcome_email(firstname, lastname):<br>    return &#39;welcome {first}. everyone please welcome {last}&#39;. format(first=firstname, last=lastname)<br><br>welcome_email(&#39;Neesha&#39;, &#39;Basnet&#39;)<br><br># output: &#39;welcome Neesha. everyone please welcome Basnet&#39;</pre><p><strong>Advantages</strong>:</p><p>a. Improves Code Readability</p><p>b. Reduces Errors and Makes Maintenance Easier.</p><p><strong>3. Iterators and List Iterators</strong></p><p>What’s an Iterator?<br> →An iterator is an object with:</p><p>I. iter() that returns the iterator object.</p><p>II. next() that returns the next value or raises StopIteration.</p><pre>lst = [1, 2, 3,4,5]<br>it = iter(lst)<br><br># lst is iterable<br># it is an iterator</pre><p>Now, using an iterator i.e using next():</p><pre>it = iter([10, 20, 30])<br>print(next(it))  # 10<br>print(next(it))  # 20</pre><blockquote><strong>My Final Thoughts:</strong><br>List comprehensions let you build lists quickly and clearly.</blockquote><blockquote>String formatting is essential for readable output.</blockquote><blockquote>Iterators is core to Python’s data handling, understanding them unlocks powerful patterns.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=315dc7729e3d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/mastering-python-list-comprehensions-string-formatting-and-iterators-315dc7729e3d">Mastering Python: List Comprehensions, String Formatting, and Iterators</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Functions: A Deep Dive into Positional & Keyword Arguments, Lambda, Map, and Filter…]]></title>
            <link>https://medium.com/intern-elite/python-functions-a-deep-dive-into-positional-keyword-arguments-lambda-map-and-filter-9cf71017c720?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf71017c720</guid>
            <category><![CDATA[python-functions]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Tue, 27 May 2025 17:23:12 GMT</pubDate>
            <atom:updated>2025-05-28T09:19:24.241Z</atom:updated>
            <content:encoded><![CDATA[<h3>DAY7 — Python Functions: A Deep Dive into Positional &amp; Keyword Arguments, Lambda, Map, and Filter Functions</h3><p>Today, I explored everything we need to know about Python functions — including positional and keyword arguments, the power of lambda functions, and how map() and filter() can make our code cleaner and faster. Here’s a breakdown of what I learned today:</p><ol><li><strong>What is a Function in Python?</strong><br> →<em>In Python, a function is a reusable block of code designed to perform a specific task. Instead of writing the same code over and over again, we wrap it into a function and just call it when needed.</em></li></ol><p>Here is a simple example of a Python Function:</p><pre>def even_odd(num):<br>    if num%2==0:<br>        print(&quot;the number is even&quot;)<br>    else:<br>        print(&quot;number is odd&quot;)<br><br>even_odd(34)</pre><p>Output: the number is even</p><p>2. <strong>Positional vs Keyword Arguments</strong></p><p>Positional Arguments</p><ul><li>Must be in the correct order</li><li>The position determines which parameter gets the value</li></ul><pre>def describe_pet(animal, name):<br>    print(f&quot;I have a {animal} named {name}&quot;)<br><br>describe_pet(&quot;dog&quot;, &quot;Rex&quot;)  # Correct order<br># Output: I have a dog named Rex</pre><p>Keyword Arguments</p><ul><li>Identified by parameter names</li><li>Order doesn’t matter</li></ul><pre>describe_pet(name=&quot;Rex&quot;, animal=&quot;dog&quot;)  # Same output<br>describe_pet(animal=&quot;dog&quot;, name=&quot;Rex&quot;)  # Also works</pre><h3>Default Values</h3><p>We can set default values for parameters:</p><pre>def describe_pet(name, animal=&quot;dog&quot;):<br>    print(f&quot;I have a {animal} named {name}&quot;)<br><br>describe_pet(&quot;Rex&quot;)  # Uses default animal<br># Output: I have a dog named Rex</pre><h3><strong>About args and kwargs:</strong></h3><pre>#args= positional argument<br>#kwargs= keyword argument<br>def hello(*args,**kwargs):<br>    print(args)<br>    print(kwargs)<br><br>hello(&quot;neesha&quot;, &quot;basnet&quot;, age=21, dob=2003)<br><br># Output: <br>(&#39;neesha&#39;, &#39;basnet&#39;)<br>{&#39;age&#39;: 21, &#39;dob&#39;: 2003}</pre><p>3.<strong> Lambda Functions: Tiny Anonymous Helpers</strong></p><p><em>What are they?<br>Lambda functions are small, one-line functions without a name.</em></p><p><em>When to use them:<br>For quick, simple operations you only need once.</em></p><p>Regular Function:</p><pre>def addition(a,b):<br>    return a+b<br><br>addition(4,5)<br><br>#output: 9</pre><p>Lambda function</p><pre>addition=lambda a,b: a+b<br>addition(12,14)<br><br>#output: 26</pre><p>3. <strong>Map: Apply a Function to Every Item</strong></p><p><em>What it does?<br> →The </em><em>map() function </em><strong><em>applies a function to every item</em></strong><em> in an iterable (like a list).</em></p><pre>def even_or_odd(num):<br>    if num%2 ==0:<br>        return &quot;{} is even&quot;.format(num)<br>    else:<br>        return &quot;{} is odd&quot;.format(num)<br><br>lst=[1,2,3,4,5]<br><br>list(map(even_or_odd,lst))<br><br>#output: [&#39;1 is odd&#39;, &#39;2 is even&#39;, &#39;3 is odd&#39;, &#39;4 is even&#39;, &#39;5 is odd&#39;]</pre><p>4.<strong> Filter: Keep Only What We Need</strong></p><p><em>What it does?<br> →Keeps only items that meet a condition.</em></p><pre>def even(num):<br>    if num %2 ==0:<br>        return True<br>lst=[1,2,3,4,4,2,86,43]<br>list(filter(even, lst))<br><br>#output: list(filter(even, lst))</pre><h3>Real-World Analogies</h3><ol><li>Functions are like kitchen appliances:</li></ol><ul><li>Blender (function) takes ingredients (arguments)</li><li>Does specific task (mixes)</li><li>Gives result (smoothie)</li></ul><p>2. Map is like an assembly line:</p><ul><li>Takes many items</li><li>Performs same operation on each</li><li>Returns transformed items</li></ul><p>3. Filter is like a sieve:</p><ul><li>Takes many items</li><li>Only lets through what matches criteria</li><li>Returns filtered items</li></ul><p><strong>What I Learned Today</strong><br>1. Functions are power tools — They help me write cleaner code that’s easier to reuse and maintain</p><p>2. Arguments have personality:</p><p>→Positional arguments are like strict teachers (order matters!)</p><p>→Keyword arguments are flexible friends (order doesn’t matter)</p><p>→Default values save time when most cases are similar</p><p>3. Lambda is my new shortcut:</p><p>→Great for quick one-time operations</p><p>→Perfect when working with map() and filter()</p><p>→But regular functions are better for complex logic</p><p>4. Map and Filter are data transformers:</p><p>→Map is like an assembly line — changes every item the same way</p><p>→Filter is like a bouncer — only lets certain items through</p><p>→Together they help process lists efficiently</p><p>5. Practice makes perfect — The more I use these concepts in real projects, the more natural they feel.</p><h3><strong>My next steps:</strong></h3><ol><li>Try these concepts in my existing projects</li><li>Experiment with combining map and filter in different ways</li><li>Explore other functional tools.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf71017c720" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/python-functions-a-deep-dive-into-positional-keyword-arguments-lambda-map-and-filter-9cf71017c720">Python Functions: A Deep Dive into Positional &amp; Keyword Arguments, Lambda, Map, and Filter…</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploratory Data Analysis (EDA) with the Titanic Dataset]]></title>
            <link>https://medium.com/intern-elite/exploratory-data-analysis-eda-with-the-titanic-dataset-6f21eaa1abfd?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f21eaa1abfd</guid>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Mon, 26 May 2025 10:56:33 GMT</pubDate>
            <atom:updated>2025-05-26T13:11:43.931Z</atom:updated>
            <content:encoded><![CDATA[<p>Exploratory Data Analysis (EDA) is one of the most crucial steps in any data science project. It helps you understand the structure of your data, uncover patterns, detect anomalies, and prepare your dataset for modeling.</p><p>In this post, I’ll walk through a full EDA workflow using the famous Titanic dataset, which contains information about passengers aboard the RMS Titanic. I downloaded Titanic dataset from kaggle. My goal is to analyze survival patterns and prepare the data for machine learning.</p><ol><li><strong>Importing libraries</strong></li></ol><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>%matplotlib inline</pre><p>We import the essential libraries:</p><p>a. pandas for handling data.</p><p>b. numpy for numeric operations.</p><p>c. matplotlib and seaborn for visualizations.</p><p>d. %matplotlib inline to display plots directly in the notebook.</p><p>2. <strong>loading dataset</strong></p><pre>train = pd.read_csv(&#39;titanic_train.csv&#39;)<br>train.head()</pre><p>I load the dataset into a DataFrame and preview the first few rows to get familiar with the columns. Key features include:</p><p>Survived: 1 = survived, 0 = did not survive.</p><p>Pclass: Ticket class.</p><p>Sex, Age, Fare, Embarked: Personal and boarding details.</p><p>3. <strong>Visualizing Missing Data</strong></p><pre>sns.heatmap(train.isnull(), yticklabels= False,cbar=False, cmap=&#39;viridis&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*PeWS9juElZQr_Q_-87Zv6w.png" /></figure><p>We use a heatmap to spot missing values. Columns like Cabin have many missing entries, while Age and Embarked have a few.</p><p>4. <strong>Understanding Distributions</strong></p><p>a. Survival Counts</p><pre>sns.set_style(&#39;whitegrid&#39;)<br>sns.countplot(x=&#39;Survived&#39;, data=train, palette=&#39;rainbow&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*moEWY7iomJ2UIdsZVH8gOA.png" /></figure><p>b. Survival by Sex</p><pre>sns.set_style(&#39;whitegrid&#39;)<br>sns.countplot(x=&#39;Survived&#39;, hue=&#39;Sex&#39;, data=train, palette=&#39;RdBu_r&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*yUrUA9KQF7CyWltdPOnAkw.png" /></figure><p>These plots show that women had a significantly higher survival rate than men.</p><p>c. Survival by Passenger Class</p><pre>sns.set_style(&#39;whitegrid&#39;)<br>sns.countplot(x=&#39;Survived&#39;, hue=&#39;Pclass&#39;, data=train, palette=&#39;rainbow&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*KDGSqnQXPd1vJ1LF7OSDEg.png" /></figure><p>First-class passengers were more likely to survive compared to those in second and third class.</p><p>d. Age Distribution</p><pre>train[&#39;Age&#39;].hist(bins=30, color=&#39;green&#39;, alpha=0.3)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*fxh7Hq9_I0SAmN8UYYTZww.png" /></figure><pre>sns.displot(train[&#39;Age&#39;].dropna(), kde=False, color=&#39;darkred&#39;,bins=40)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*Yy0s9CkvSAGP-FTvj0aDzw.png" /></figure><p>e. Sibling/Spouse Aboard Count</p><pre>sns.countplot(x=&#39;SibSp&#39;, data=train)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*coKyUJyiJs01AMvfSNKR1A.png" /></figure><p>5. <strong>Data Cleaning</strong></p><p>We want to fill in missing age data instead of just dropping the missing age data rows . one way to do this is by filling in the mean age of all the passengers (imputation). However we can be smarter about this and check the average age by passenger class. For example:</p><p><strong>a</strong>. Identifying missing age by class: This shows average age by class (1st, 2nd, 3rd) to help impute missing values more intelligently.</p><pre>plt.figure(figsize=(12,7))<br>sns.boxplot(x=&#39;Pclass&#39;, y=&#39;Age&#39;, data=train, palette=&#39;winter&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*w08EtgC4eW-oinuh813KjQ.png" /></figure><p><strong>b</strong>. Imputation Function: Defines a function to fill missing Age values based on Pclass. Uses typical average ages: 1st class -&gt;37, 2nd -&gt;29, 3rd -&gt;24.</p><pre>def impute_age(cols):<br>    Age= cols[0]<br>    Pclass= cols[1]<br><br>    if pd.isnull(Age):<br>        if Pclass==1:<br>            return 37<br>        elif Pclass == 2:<br>            return 29<br>        else:<br>            return 24<br>        <br>    else:<br>        return Age</pre><p><strong>c</strong>. Apply Imputation: This code applies the custom function to fill in the missing Age values.</p><pre>train[&#39;Age&#39;] = train[[&#39;Age&#39;,&#39;Pclass&#39;]].apply(impute_age, axis=1)</pre><p><strong>d</strong>. Re-checking missing values: Recheck missing values after fixing age.</p><pre>sns.heatmap(train.isnull(),yticklabels=False, cbar=False,cmap=&#39;viridis&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*2u4QyZggesF0rbgzsIKHIw.png" /></figure><p><strong>e</strong>. Drop ‘Cabin’ Column: There is too many missing values in Cabin, so it’s dropped completely.</p><pre>train.drop(&#39;Cabin&#39;, axis=1, inplace=True)</pre><p><strong>f</strong>. Remove Remaining Null Rows: It will drop any remaining rows with null values.</p><pre>train.dropna(inplace=True)</pre><p>6. <strong>Converting Categorical features</strong></p><p>We’ll need to convert categorical features to dummy variables using pandas. otherwise our machine learning algorithm wont be able to directly take in those features as inputs.</p><p><strong>a. View info</strong>: Gives a summary of data types and non-null counts.</p><pre>train.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*sDyQQaTa5rFpKCuIe8vZOw.png" /></figure><p><strong>b. Create Dummy Variables</strong>: Converts Sex into male (1) or female (0), dropping one to avoid redundancy.</p><p>Converts Embarked into two columns (e.g., Q and S, dropping C).</p><pre>sex = pd.get_dummies(train[&#39;Sex&#39;], drop_first=True)<br>embark= pd.get_dummies(train[&#39;Embarked&#39;], drop_first=True)</pre><p><strong>c. Drop Unneeded Columns</strong>: Remove original categorical columns and irrelevant ones (Name, Ticket).</p><pre>train.drop([&#39;Sex&#39;,&#39;Embarked&#39;, &#39;Name&#39;, &#39;Ticket&#39;], axis=1,inplace=True)</pre><p><strong>d. Merge Dummy Variables</strong>: Add the dummy columns to the main dataset.</p><pre>train=pd.concat([train,sex,embark],axis=1)<br>train.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*Ux-zwNIXDslQg2t5SgdZ8w.png" /></figure><p>7. <strong>Building a Logistic Regression Model</strong></p><p>Logistic Regression is a statistical and machine learning method used to predict binary outcomes — situations where the result is one of two possible values (like Yes/No, Win/Loss, Survived/Not Survived).</p><p>Despite its name, logistic regression is used for classification, not regression.</p><p>lets start by spitting our data into a training set and test set.</p><p>Training set: Used to teach the model (70% of the data).</p><p>Testing set: Used to test how well the model learned (30% of the data).</p><p><strong>a</strong>. spilted the dataset</p><pre>from sklearn.model_selection import train_test_split<br><br>X_train, X_test, y_train, y_test = train_test_split(<br>    train.drop(&#39;Survived&#39;, axis=1), <br>    train[&#39;Survived&#39;], <br>    test_size=0.3, <br>    random_state=101<br>)</pre><p><strong>lets decode this code</strong>;</p><p><strong>from sklearn.model_selection</strong>: You are importing a module from scikit-learn, which is a popular Python library for machine learning.</p><p><strong>train_test_split</strong>: This is a function provided by scikit-learn that helps you split your dataset into two parts:</p><p>a.<strong>Training set </strong>(to train the model)</p><p>b<strong>.Testing set</strong> (to evaluate the model)</p><p>The model learns from X_train and y_train. Then it is evaluated on X_test and y_test</p><p><strong>.drop(‘Survived’, axis=1)</strong>: this removes the Survived column from the dataset because Survived is the label/output — we don’t want it as part of the features (inputs).</p><p><strong>axis=1</strong> means you’re dropping a column (if it were axis=0, you’d drop a row).</p><p><strong>train[‘Survived’]</strong>: This selects the Survived column from the DataFrame ,the target variable we want to predict. This becomes your y (label).</p><p><strong>test_size=0.3:</strong> This tells the function to use 30% of the data for testing, and the remaining 70% for training.</p><p><strong>random_state=101</strong>: This sets the random seed — making sure the data split is always the same every time you run the code. Without this, the data split could change each time, making it hard to compare results. You can use any integer value.</p><p><strong>b</strong>. Train the model</p><pre>from sklearn.linear_model import LogisticRegression<br>logmodel = LogisticRegression()<br>logmodel.fit(X_train, y_train)</pre><p>You import the LogisticRegression class from sklearn, a popular Python library for ML. logmodel is your model object.</p><p><strong>.fit(X_train, y_train)</strong>: This is where the training happens. It learns the patterns between the features (X) and the target (y).</p><p>For example: If a person is female, from 1st class, and young → they probably survived.</p><p><strong>c</strong>. Make prediction</p><p>Now, our model is done learning, and it’s time to test it. <strong>.predict(X_test)</strong> asks the model to guess who survived in the test dataset.</p><pre>predictions = logmodel.predict(X_test)</pre><p><strong>d</strong>. Evaluate Model Accuracy</p><p>i. Confusion Matrix:</p><pre>from sklearn.metrics import confusion_matrix<br>confusion_matrix(y_test, predictions)</pre><p>It shows:</p><p>a. How many survivors were correctly predicted.</p><p>b. How many non-survivors were wrongly predicted as survivors, etc.</p><p>ii. Accuracy Score</p><pre>from sklearn.metrics import accuracy_score<br>accuracy = accuracy_score(y_test, predictions)<br>accuracy</pre><p>This gives you a number between 0 and 1. 0.85 means the model got 85% of the predictions correct. The higher the better but 100% usually means overfitting.</p><p>Through EDA, I :</p><p>a. Explored the data visually and statistically.</p><p>b. Handled missing values and cleaned the dataset.</p><p>c. Converted categorical variables.</p><p>d. Built and evaluated a predictive model.</p><p>EDA not only prepares our data for modeling but also helps us understand the story behind the numbers. The Titanic dataset is a perfect starting point to build our EDA intuition and data science workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f21eaa1abfd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/exploratory-data-analysis-eda-with-the-titanic-dataset-6f21eaa1abfd">Exploratory Data Analysis (EDA) with the Titanic Dataset</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Seaborn Explained Simply: Heatmaps, Histograms, and More]]></title>
            <link>https://medium.com/intern-elite/seaborn-explained-simply-heatmaps-histograms-and-more-01538e7bc1ac?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/01538e7bc1ac</guid>
            <category><![CDATA[seaborn-tutorial]]></category>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Sun, 25 May 2025 11:29:22 GMT</pubDate>
            <atom:updated>2025-05-26T04:12:19.067Z</atom:updated>
            <content:encoded><![CDATA[<p>I started learning Seaborn because I wanted to understand my data visually. At first, I found the plots confusing, but once I understood what each one was for, it all started to click. Here’s everything I learned — with simple explanations and code.</p><p>Seaborn is a Python data visualization library based on Matplotlib. It makes it easy to create beautiful and informative statistical graphics using just a few lines of code.</p><p>Today, I learnt about seaborn along with its sub-topics : correlation and heatmap, jointplot, univariate analysis, pairplots, categorical plots, etc.</p><p>Step 1: <strong>Importing seaborn</strong></p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt</pre><p>Now, I am taking “tips” dataset which contains restaurant tips data.</p><pre>df=sns.load_dataset(&quot;tips&quot;)</pre><p>After this I am diving into different topics.</p><ol><li><strong>Correlation with Heatmap</strong></li></ol><p>A correlation heatmap uses colored cells, typically in a monochromatic scale to show a 2D correletaion matrix (table) between two discrete dimensions or event types. It is very important in Feature Selection</p><pre>df.corr(numeric_only=True)<br>sns.heatmap(df.corr(numeric_only=True))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*3E7TbAfbzYSmn2qThov6Ew.png" /></figure><p>2. <strong>JointPlot</strong></p><p>A join plot allows to study the relationship between 2 numeric variables. The central chart display their corrrelation. It is usally a scatterplot , a hexbin plot , a 2D histogram or a 2D density plot.</p><p>-Univariate Analysis</p><pre>sns.jointplot(x=&#39;tip&#39;, y=&#39;total_bill&#39;, data=df, kind=&#39;hex&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*J9lZILOmr0scF_ZaJZqBjw.png" /></figure><pre>sns.jointplot(x=&#39;tip&#39;, y=&#39;total_bill&#39;, data=df, kind=&#39;reg&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*BibLEoU3HSEPGGa2WKkpWQ.png" /></figure><p>3. <strong>Pair plot</strong></p><p>A ‘pair plot’ is also known as a scatterplot, in which one variable in the same data row is matched with another variable’s value, like this: Pairs plot are just elaborations on this , showing all variables paired with all the other variables.</p><pre>sns.pairplot(df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*EurcklA0rfV9P7JckyQopg.png" /></figure><pre>sns.pairplot(df, hue=&#39;sex&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*Yz2yjn-gxPHF0UUuc-NYMw.png" /></figure><p>4. <strong>Dist plot</strong></p><p>Dist plot helps use to check the distribution of the columns feature</p><pre>sns.distplot(df[&#39;tip&#39;])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*6svnCXIgtjArzA2GhOyUsA.png" /></figure><pre>sns.distplot(df[&#39;tip&#39;], kde= False, bins=10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*PhzN0lF6trjJlwhSTr_1xg.png" /></figure><p>5. <strong>Histplot</strong></p><pre>sns.histplot(df[&#39;tip&#39;], kde= False, bins=10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*cvlrihYnfzKyUnvm_V5mxw.png" /></figure><p>6. <strong>Categorical Plots</strong></p><p>Seaborn also helps us in doing the analysis on CAtegorical data points. In this section, we will discuss about</p><p>a. Boxplot</p><p>b. violinplot</p><p>c. countplot</p><p>d. bar plot</p><p><strong>a. count plot</strong></p><pre>sns.countplot(x=&#39;smoker&#39;, data=df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*-fTQFhaXIkogBUgW-6SXIw.png" /></figure><pre>sns.countplot(x=&#39;day&#39;, data=df, palette= &#39;Set1&#39;)<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*Wvclgj9BhMBytcbOMPV16g.png" /></figure><p><strong>b. Bar plot</strong></p><pre>sns.barplot(x=&#39;total_bill&#39;, y=&#39;smoker&#39;, data=df, palette=&#39;Set2&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*zPZq0to-8Qp6MWKDPCF_og.png" /></figure><p>c. <strong>Box plot</strong></p><p>A box and whisker plot (sometimes called a boxplot) is a graph that presensts information from a five-number summary.</p><pre>sns.boxplot(x=&#39;sex&#39;, y=&#39;total_bill&#39;, data=df, palette=&#39;Set3&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*p_YbP-p4UB3gjBOi8bcBcg.png" /></figure><pre>sns.boxplot(data=df, orient=&#39;v&#39;)<br># seaborn will automatically Pick all numeric columns (total_bill, tip, size)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*fg0zsuzqFI4TgbIzy7HbPQ.png" /></figure><pre>sns.boxplot(x=&#39;total_bill&#39;, y=&#39;day&#39;, hue=&#39;smoker&#39;, data=df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*QsmU-7rhYbi2SOMYPdE0Rw.png" /></figure><p>d. v<strong>iolin plot</strong></p><p>Violin plot helps us to see both the distribution of data in terms of kernel density estimation and the box plot.</p><pre>sns.violinplot(x=&#39;total_bill&#39;, y=&#39;day&#39;,data=df, palette=&#39;rainbow&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*mYGU8PE9cGzzJ2LRmx29AQ.png" /></figure><p>Seaborn turned out to be an incredibly efficient tool for data visualization. From exploring distributions with histograms to understanding relationships using pair plots and heatmaps, it covers almost every essential chart a data analyst or data scientist needs. The simplicity of its syntax combined with the quality of its output makes it a must-have in any data workflow. Whether you’re working on exploratory data analysis or presenting insights, Seaborn helps us tell the story behind our data clearly and beautifully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01538e7bc1ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/seaborn-explained-simply-heatmaps-histograms-and-more-01538e7bc1ac">Seaborn Explained Simply: Heatmaps, Histograms, and More</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day5 — COVID-19 Data Analysis: How I Used Pandas, NumPy, and Matplotlib to Visualize Trends]]></title>
            <link>https://medium.com/intern-elite/day5-covid-19-data-analysis-how-i-used-pandas-numpy-and-matplotlib-to-visualize-trends-6fbffb60cc5a?source=rss-8d1625d4644d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fbffb60cc5a</guid>
            <dc:creator><![CDATA[Neesha Basnet]]></dc:creator>
            <pubDate>Fri, 23 May 2025 04:10:08 GMT</pubDate>
            <atom:updated>2025-05-23T05:09:17.890Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day5 — COVID-19 Data Analysis: How I Used Pandas, NumPy, and Matplotlib to Visualize Trends</h3><p>Recently, I completed a mini-project to analyze and visualize COVID-19 data using Python libraries pandas, numpy, and matplotlib. This project helped me understand basic data analysis and visualization techniques with real-world inspired data.</p><ol><li><strong>Loading the Data with Pandas:</strong><br> I started by importing the essential libraries and loading a small CSV file containing daily COVID-19 case numbers, deaths, and recoveries.</li></ol><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br><br>df = pd.read_csv(&quot;covid19_sample_data.csv&quot;)<br>df[&#39;Date&#39;] = pd.to_datetime(df[&#39;Date&#39;])</pre><p>Here, pd.read_csv() loads the dataset, and I converted the ‘Date’ column to a datetime format for better plotting and analysis.</p><p><strong>2. Calculating Additional Metrics</strong><br>Using pandas, I added a new column Active to track active COVID-19 cases:</p><pre>df[&#39;Active&#39;] = df[&#39;Confirmed&#39;] - df[&#39;Deaths&#39;] - df[&#39;Recovered&#39;]</pre><p>To find the number of daily new cases, I used pandas .diff() method, which calculates the difference between each row and the previous one:</p><pre>df[&#39;New Cases&#39;] = df[&#39;Confirmed&#39;].diff().fillna(0).astype(int)</pre><p>Here,</p><p>diff() -&gt; computes the difference between each row and the previous row in the ‘Confirmed’ column, effectively calculating new cases per day.</p><p>fillna(0)-&gt; replaces the first row’s NaN (because the first diff has no previous value) with 0.</p><p>.astype(int)-&gt; converts the floating-point results into integers.</p><p>3. <strong>Exploring the Data with Basic Statistics</strong><br>Using df.describe(), I reviewed summary statistics like mean, max, and count for each column. This is a quick way to understand the data distribution.</p><pre>print(df.describe())</pre><p>4. <strong>Visualizing the Data with Matplotlib</strong></p><p>Visualization is key to understanding trends. I plotted the confirmed, recovered, deaths, and active cases over time using line plots:</p><pre>x = df[&#39;Date&#39;]<br><br>plt.figure(figsize=(12, 6))<br>plt.plot(x, df[&#39;Confirmed&#39;], label=&#39;Confirmed&#39;, marker=&#39;o&#39;)<br>plt.plot(x, df[&#39;Recovered&#39;], label=&#39;Recovered&#39;, marker=&#39;o&#39;)<br>plt.plot(x, df[&#39;Deaths&#39;], label=&#39;Deaths&#39;, marker=&#39;o&#39;)<br>plt.plot(x, df[&#39;Active&#39;], label=&#39;Active&#39;, marker=&#39;o&#39;)<br><br>plt.title(&#39;COVID-19 Case Trends&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.ylabel(&#39;Number of Cases&#39;)<br>plt.legend()<br>plt.grid(True)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37Zg5RUI_7W7DLejn38N2Q.png" /></figure><p>Here,</p><p>plt.legend()-&gt; Adds a legend (a small box or area) on the plot that explains what each line or plotted element represents.</p><p>plt.tight_layout()-&gt; Automatically adjusts subplot parameters (margins, spacing) so that labels, titles, and ticks don’t overlap or get cut off.</p><p>plt.xticks(rotation=45) -&gt; Rotate date labels</p><p>I also created a bar chart to visualize the daily new cases:</p><pre>x= df[&#39;Date&#39;]<br>y = df[&#39;New Cases&#39;]<br><br>plt.bar(x,y, align=&#39;center&#39;, color=&#39;orange&#39;)<br>plt.xlabel(&#39;date&#39;)<br>plt.ylabel(&#39;new cases&#39;)<br>plt.title(&#39; daily new cases&#39;)<br>plt.xticks(rotation= 45)<br>plt.tight_layout()<br>plt.show()<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*iq79Lzu8S4Kt_vK-w1HEAA.png" /></figure><p>I also plotted line graphof active cases over time to track how many people were currently infected.</p><pre><br>plt.figure(figsize=(10, 4))<br>plt.plot(df[&#39;Date&#39;], df[&#39;Active&#39;], label=&#39;Active Cases&#39;, color=&#39;purple&#39;, marker=&#39;o&#39;)<br><br>plt.title(&#39;Active COVID-19 Cases Over Time&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.ylabel(&#39;Active Cases&#39;)<br>plt.xticks(rotation=45)<br>plt.legend()<br>plt.grid(True)<br>plt.tight_layout()<br>plt.show()<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*TX9uE2vecAlMYjT2UiDG-Q.png" /></figure><p><strong>— -What I Learned:</strong><br>-Pandas makes it easy to load, manipulate, and calculate new data columns.</p><p>-NumPy can help with numerical operations, though in this project, pandas .diff() handled most calculations efficiently.</p><p>-Matplotlib is great for plotting different chart types to explore and present data insights visually.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fbffb60cc5a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intern-elite/day5-covid-19-data-analysis-how-i-used-pandas-numpy-and-matplotlib-to-visualize-trends-6fbffb60cc5a">Day5 — COVID-19 Data Analysis: How I Used Pandas, NumPy, and Matplotlib to Visualize Trends</a> was originally published in <a href="https://medium.com/intern-elite">Intern Elite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>