<?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 Khondokar Saim on Medium]]></title>
        <description><![CDATA[Stories by Khondokar Saim on Medium]]></description>
        <link>https://medium.com/@saimw1083?source=rss-7aca7b13bcb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pX4pspQ6ZsX160EyneeJhQ.png</url>
            <title>Stories by Khondokar Saim on Medium</title>
            <link>https://medium.com/@saimw1083?source=rss-7aca7b13bcb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:11:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saimw1083/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[Python Programming Basics for Data Science [Part 4: Python Control Flow Statements and Loops]]]></title>
            <link>https://medium.com/@saimw1083/python-programming-basics-for-data-science-part-4-python-control-flow-statements-and-loops-228f07190892?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/228f07190892</guid>
            <category><![CDATA[python-loop]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-dictionaries]]></category>
            <category><![CDATA[python-control-flow]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Fri, 29 May 2026 18:26:34 GMT</pubDate>
            <atom:updated>2026-05-29T18:26:34.119Z</atom:updated>
            <content:encoded><![CDATA[<p>We would have come across a situation where we have to choose between the options based on the situation. What if we want to implement it by coding? Python provides constructs for this purpose.</p><p>In Python programming, flow control is the order in which statements or blocks of code are executed at runtime based on a condition.</p><h3>1. Control Flow Statements</h3><p>The flow control statements are divided into <strong>three categories</strong></p><ol><li><strong>Conditional statements</strong></li><li><strong>Iterative statements.</strong></li><li><strong>Transfer statements</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*fDq_wdhXCxbRedNCDdzArA.png" /></figure><h3>1.1 Conditional Statements in Python</h3><p>Did you ever get a pop-up message when you forgot to fill any of the fields in a form? We get this message because in the backend the program checks for empty fields. And if it comes across any of them, it alerts, else it submits the form.</p><p>Like this, there are many cases where we need to use conditionals while programming to take further steps. For these purposes, Python provides the following constructs:</p><p><strong>1. If statements</strong></p><p><strong>2. If-else statements</strong></p><p><strong>3. Elif ladders</strong></p><p><strong>4. Nested if-else statements</strong></p><p>We will discuss each of them with examples in the following sections of this article.</p><h4>✦ Python If statements</h4><p>If statements take an expression, which is the condition it checks. If the condition is satisfied then it executes the block of code under it, called the body. If the condition is not satisfied then it skips the execution of the body and executes the further code, if any. The syntax is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*L257DJGT2iv00vnqYmbYcw.png" /></figure><p>The statements form the body of the if block. It is important to give the gap (tab or four spaces) for the statements, only then the statements will be considered as a part of the body. And this procedure is called indentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/0*YFFF6d8JuWW6jXJA.jpg" /></figure><p>◾ <strong>Example of an if-statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*DCmaIEsWawnYCq8fh4z74A.png" /></figure><h4>1. Values as expressions</h4><p>It printed that the number is positive only because the condition ‘n&gt;0’ is True. The expression can even be a number or a string or a sequence. Remember, these are considered True if they are non-empty/ 0 else False. The expression can also be a boolean.</p><p>◾ <strong>Example of if-statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*JWBV8mSVBLV4unaY7g7JIA.png" /></figure><h4>2. Using parentheses for the expression:</h4><p>We can also enclose the expression in the brackets as shown below.</p><p>◾<strong>Example of if-statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*kTCEnPzLhhpZJRjo5mlfeA.png" /></figure><h4>3. Giving proper indentation</h4><p>However, if we do not indent the block of the code, we get an error asking us to indent properly. We also get an error if we don’t add the colon (:) after the expression. The below example shows this.</p><p>◾<strong>Example of getting an indentation error:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*I99Gdg4gFvlLMkvXpTDY6A.png" /></figure><h4>◾Real-Life Scenario Examples of if Statements in Python</h4><p>if statements are used in real life to make decisions.<br> Just like humans make decisions based on conditions, programs do the same.</p><p><strong>ATM Balance Check:</strong></p><p>You try to withdraw money from an ATM.<br> The ATM checks if your balance is enough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*7-2vQDSa86O2qpH9Kyx_oA.png" /></figure><p>Since 5000 &gt;= 2000 is True, The withdrawal is allowed.</p><p><strong>Door Lock Security System:</strong></p><p>A smart door opens only if the fingerprint matches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*uS2VBmPM-bxb2QEuV9XHbg.png" /></figure><h4>✦ Python If-else statements</h4><p>We saw above that if the condition is True then the block of code is executed. What if we want a different action to take place if the expression gives False?</p><p>This is the case where we use the if-else statements. If the condition is True, the statements under if block executes, or else, the ones under the else block executes. The syntax is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*n7Gj8JmW_Pp3NcaWl-T5yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*cJCz8Pn782tsnC2D.jpg" /></figure><p>◾<strong>Example of if-else statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*HnMz11lal_YTxQEUgED6GA.png" /></figure><h4>1. Giving proper indentation</h4><p>Again, an important thing to note is the indentation. Look at the below example for more understanding.<br>◾<strong>Example of getting an error on not indenting:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*p2RA3GMvpNRljwIcCSzSNw.png" /></figure><p>We got an error above because the else cannot be inside the if block, we have to make its indentation aligned to that of the if expression.</p><h4>2. Writing more than one else block</h4><p>Another important point is that we cannot have more than one else block. We get a SyntaxError if we use more than one else block for an if-else statement.</p><p>◾<strong>Example of getting an error on writing more than one else statements:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*woyzzp2LYPcBlVYIE95OCg.png" /></figure><h4>◾Real-Life Scenario Examples of if-else Statements in Python</h4><p>An if-else statement helps programs make decisions, just like humans do in daily life.</p><p><strong>Weather Decision:</strong></p><p>If it is raining, take an umbrella. Otherwise, go normally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*95s2ZUPEeNbho6SKYjdsKQ.png" /></figure><p><strong>Traffic Signal System:</strong></p><p>Cars move if the light is green; otherwise, they stop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*-QC0PAzJLFgpaP_6X1W52g.png" /></figure><h4>✦ Python elif ladder</h4><p>We saw above that we get an error if we include more than one else statement. So, we can only check for one condition and have only two cases. What if we have wanted to give more than one option?</p><p>We can use elif ladder to have more than two cases. It checks the conditions till it reaches that line where the expression is satisfied and executes the corresponding block of code. The syntax is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*pKwrq5s7cG_IUa0owBHWww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*DLOzXAdUqSEDa-Pr.jpg" /></figure><p>◾<strong>Example of elif ladder:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*LrjYgM-_aBSKCn2fFVtPFQ.png" /></figure><h4>1. The syntax rules of the elif ladder</h4><p>Important points to note regarding the syntax are:</p><p>1. Indentation: All the statements should have spaces. All the if, elif, and else expressions should not have any space and should be aligned.</p><p>2. It is elif, and not else if</p><p>3. There should be an expression for every elif</p><p>An example of these errors are shown below:</p><p>◾<strong>Example of getting an error on using the wrong syntax for elif ladder:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*4kBDMLGZ_spYu-dnwQj5YA.png" /></figure><h4>2. Can skip the else part</h4><p>We can skip the else block as shown below.</p><p>◾<strong>Example of elif ladder without else block:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*eRypZveNjFG0lBONp0CSIg.png" /></figure><h4>◾Real-Life Scenario Examples of elif Ladder in Python</h4><p>An elif ladder is used when we have <strong>multiple possible decisions</strong>, and only <strong>one condition should be selected</strong>.</p><p>It works like real-life decision making where we choose one option among many.</p><p><strong>Exam Grade System:</strong></p><p>Schools assign grades based on marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*eIbjvQf36S-j580A6L23tA.png" /></figure><p><strong>E-commerce Delivery Time:</strong></p><p>Online shops estimate delivery time based on location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*WYub0f_9zVMaCtMMfaISOQ.png" /></figure><h4>✦ Python Nested if-else statements</h4><p>This is another choice to give more than two cases. In this, we have if-else blocks inside either if or else blocks. These are useful when we have to check a series of conditions. The syntax is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*T-OOhAxlTQqb6ehLd5yvcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/0*Qt4NAFghkdipiCH8.jpg" /></figure><p>◾<strong>Example of nested if-else:</strong></p><p><strong>ATM Withdrawal with Security Check (Nested if-else)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*aaD_96vLbXTqz_bWQaxy2g.png" /></figure><p>In this ATM example, nested if-else is used to handle a multi-level decision process. First, the system checks the PIN using the outer if condition. If the PIN is correct, it enters the inner if block to check whether the account balance is enough for the withdrawal. If the balance is sufficient, the transaction is completed successfully; otherwise, it shows an insufficient balance message. If the PIN is incorrect, the outer else block runs and access is denied, meaning the balance check is not used for approval. This structure ensures that security validation happens first, followed by financial validation only when the user is authenticated.</p><h3>1.2 Iterative Statements in Python</h3><p><strong>Iteration statements, </strong>commonly known as loops, are statements in programming used to execute part of code repeatedly based on condition or set of conditions. These constructs are important for performing repetitive tasks efficiently. In this article, we will discuss various types of iteration statements and their use in different programming languages.</p><p>Types of Iteration Statements in programming:</p><p>There are mainly three types of iteration statements:</p><ul><li><strong>For Loop</strong></li><li><strong>While Loop</strong></li><li><strong>Nested Loop</strong></li></ul><p>In programming, the loops are the constructs that repeatedly execute a piece of code based on the conditions. These are useful in many situations like going through every element of a list, doing an operation on a range of values, etc.</p><p>There are two types of loops in Python and these are for and while loops. Both of them work by following the below steps:</p><p>1. Check the condition<br>2. If True, execute the body of the block under it. And update the iterator/ the value on which the condition is checked.<br>3. If False, come out of the loop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*B11E7HFNmS_oTRqr.jpg" /></figure><p>Now let us discuss each of the loop types in the following sections.</p><h4>✦ Python For Loop</h4><p>In Python, the for loop is used to iterate over a sequence such as a <a href="https://pynative.com/python-lists/">list</a>, string, <a href="https://pynative.com/python-tuples/">tuple</a>, other iterable objects such as <a href="https://pynative.com/python-range-function/">range</a>.</p><p>With the help of for loop, we can iterate over each item present in the sequence and executes the same set of operations for each item. Using a for loops in Python we can automate and repeat tasks in an efficient manner.</p><p>So the bottom line is using the for loop we can repeat the block of statements a fixed number of times. Let’s understand this with an example.</p><ul><li><strong>Fixed number of times</strong>: Print the multiplication table of 2. In this case, you know how many iterations you need. Here you need 10 iterations. In such a case use for loop.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SzKTrnk4BstwT4ciTRSQfg.png" /></figure><p><strong>Syntax of </strong><strong>for loop</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*TZDfHCyg_14Ja6omEBQgKQ.png" /></figure><ul><li>In the syntax, i is the iterating variable, and the range specifies how many times the loop should run. For example, if a list contains 10 <a href="https://pynative.com/python-numbers/">numbers</a> then for loop will execute 10 times to print each number.</li><li>In each iteration of the loop, the variable i get the current value.</li></ul><p>◾<strong>Example 01 : Print first 5 numbers using a for loop</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*-QMK47tcQcJl_Dws0Ig_-Q.png" /></figure><ul><li>Here we used the range() function to generate integers from 0 to 4</li><li>Next, we used the for loop to iterate over the numbers produced by the range() function</li><li>In the body of a loop, we printed the current number.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/0*PQ-LO6du1Pw6eZaz.png" /></figure><h3>How for loop works</h3><p>The for loop is the easiest way to perform the same actions repeatedly. For example, you want to calculate the square of each number present in the <a href="https://pynative.com/python-lists/">list</a>.</p><p>Write for loop to iterate a list, In each iteration, it will get the next number from a list, and inside the body of a loop, you can write the code to calculate the square of the current number.</p><p>◾<strong>Example: Calculate the square of each number of list</strong></p><p>Python list is an ordered sequence of items. Assume you have a list of 10 numbers. Let’s see how to want to calculate the square of each number using for loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*wU20UXdnqpPnGqP9ZrefgQ.png" /></figure><p><strong>Note</strong>:The loop runs till it reaches the last element in the sequence. If it reaches the last element in the sequence, it exits the loop. otherwise, it keeps on executing the statements present under the loop’s body</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*XhH1nwoSAqDY_BtejAD6yg.png" /></figure><h4>Iterating through range() objects:</h4><p>range() is a <a href="https://data36.com/python-built-in-functions-methods-python-data-science-basics-3/">built-in function</a> in Python and we use it almost exclusively within for loops. What does it do? In a nutshell: it generates a list of numbers. Let’s see how it works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*hV7q1PKySbK_3_Vedayy1g.png" /></figure><p>It accepts three arguments:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GJRlS_gWQSfD4394.png" /></figure><ul><li><strong>First element:</strong> The starting value of the range.</li><li><strong>Last element:</strong> This is not included in the range. Python stops just before it. For example, range(0, 10) gives numbers from 0 to 9.</li><li><strong>Step:</strong> The gap between numbers. If the step is 2, every second number will be shown.</li></ul><p>Now, can you guess the result of the range above? Here it is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*tpcun6pn0NAqIo_NcRjRbg.png" /></figure><p>When range() can be useful? Mostly, in these two cases:</p><p>◾<strong>Sending reminders every 2 hours</strong><br>Suppose you want to send reminders from 8 AM to 6 PM every 2 hours:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*-Q4AuOiiUzMGzk0LYkk2cw.png" /></figure><p>◾<strong>Checking student roll numbers</strong><br>Imagine a teacher wants to check attendance for students with roll numbers 1 to 5:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*sZyi-Ab1yLTWvbYZwhrkjw.png" /></figure><h4>Looping over the iterables:</h4><p>To iterate over the iterables like list, string, set, tuple, and dictionary, for loop is the most common approach used by the programmers. In this instead of using the range() function, we loop over the iterable. While in the case of dictionaries, the iterable loops over the keys. So we can use the iterable to get the corresponding value.</p><p>The below examples show the use of for loop over each iterable.</p><p>◾<strong>Example of iterating over list:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*8Mh8NKZn72P2FPpUj48iRg.png" /></figure><blockquote>Real-World Scenario: <em>Grocery Shopping</em><br>You have a shopping list and want to check off each item one by one.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*a6QsA7V8ULXB5SAX_y_a-g.png" /></figure><p><em>Lists keep order and allow repeats. Perfect for queues, checklists, or step-by-step tasks.</em></p><p>◾<strong>Example of iterating over a set:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*OoUsbJO93jsY3Uqlo63OsA.png" /></figure><blockquote>Real-World Scenario: <em>Party Guest Check-In</em><br>You only want to greet each guest once, even if their name was added twice by mistake.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*bsnGqxx_Cr3b9Nw5eC7zLQ.png" /></figure><p><em>Sets automatically remove duplicates. Great for counting unique visitors, tags, or items.</em></p><p>◾<strong>Example of iterating over a tuple:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*sSr424prK0yHQ9j2pWJhmw.png" /></figure><blockquote>Real-World Scenario: <em>Fixed Work Schedule</em><br>Your workdays never change, so you store them in a tuple and print the daily schedule.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*zM4Zz1BESGqe6mBURdm9fw.png" /></figure><p><em>Tuples are fixed and unchangeable. Ideal for constants like days, months, or settings.</em></p><p>◾<strong>Example of iterating over a string:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*ZE0A6p6xyGXfbs7TD1NoiA.png" /></figure><blockquote>Real-World Scenario: <em>Reading a Security Code</em><br>You need to process a short password or code one letter at a time.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*s-s-AidmLBgvRG6QZk_3UA.png" /></figure><p><em>Strings are just sequences of characters. Looping over them lets you read, count, or validate text.</em></p><p>◾<strong>Example of iterating over a dictionary:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*2oLdZWeAkXiVz6oh0lQ9fA.png" /></figure><blockquote>Real-World Scenario: <em>Printing Report Cards</em><br>You have student names and their scores. Loop through the dictionary to display each one.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*y5Binn7n5aYQe9X994ghiQ.png" /></figure><p><em>Looping over a dictionary gives you the keys. Use </em><em>dictionary[key] to get the matching value.</em></p><h4>Iterating using indices:</h4><p>An alternate method used to loop over the ordered iterables is to find the length using the len() function. And then using it as the argument to the range() function. Then using the iterable as an index to access the elements of the iterable.</p><p>The below example shows the way to do so on the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*ATO3CNYdb5Gt9gswRMZVww.png" /></figure><blockquote>Real-World Scenario: <em>Numbered Task List</em><br>You want to show each task with a number so users know the exact order.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*UEXd-suFvh9jAtryZ0Wk0A.png" /></figure><p><em>Use indices when you need the position number or when working with multiple lists at the same time.</em></p><h4>✦ Python for loop using in if-else statement</h4><p>The combination of loops and conditionals is where Python becomes truly powerful. You can filter, categorize, or transform data based on logical conditions inside the loop.</p><p>◾<strong>Example of iterating over an if-else statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*mgwGlA_TU2711hWJ6ambkQ.png" /></figure><blockquote>Real-Life Scenario: Bank Transaction Filtering.</blockquote><blockquote>A bank processes a list of transaction amounts. Transactions above a certain threshold require manual approval, while smaller ones are approved automatically.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*S6Tj63cT9rO2wW_6ks_M-w.png" /></figure><h4>✦ Reverse for loop</h4><p>In the previous sections, we covered forward iteration over iterables using indices and direct element access. However, there are many situations where you need to traverse data in reverse order. For example, displaying chat messages from newest to oldest, processing financial transactions from most recent to oldest, or reversing a list without creating a copy.</p><p>Python provides three elegant ways to achieve reverse looping.</p><ol><li>Reverse For Loop Using <strong>Range</strong> with Negative Step.</li><li>Reverse For Loop Using the <strong>Reversed Function</strong>.</li><li>Reverse For Loop Using <strong>Slicing with Negative Step.</strong></li></ol><h4>1. Reverse For Loop Using Range with Negative Step</h4><p>The range() function accepts three parameters: start, stop, and step. By using a negative step value, you can generate indices in descending order. This method is particularly useful when you need to access elements by their position or modify the original sequence.</p><p>Syntax: range(start_index, stop_index, -1)</p><p>◾<strong>Example: Playing a Song Playlist in Reverse.</strong></p><p>A music player has a queue of songs. The user selects the “reverse play” feature, which plays songs from last to first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*Prq00qAHeeSk9_1tvzQpsg.png" /></figure><h4>2. Reverse For Loop Using the Reversed Function</h4><p>The reversed() function is the most Pythonic and readable way to iterate backward over any iterable. It returns an iterator that yields elements in reverse order without modifying the original sequence. This method works on lists, tuples, strings, and any sequence that supports __reversed__().</p><p>◾<strong>Example: Displaying Student Grades in Reverse Order.</strong></p><p>A teacher enters grades into a gradebook as they are submitted. At the end of the term, the teacher wants to see the most recent grades first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*Ow1q47n2oHCyLrp_a6WfWg.png" /></figure><h4>3. Reverse For Loop Using Slicing with Negative Step</h4><p>A third alternative is using list slicing with a negative step: for item in iterable[::-1]. This creates a new reversed copy of the sequence. While readable, it uses additional memory and is less efficient than reversed() for large sequences.</p><p>◾<strong>Example: Product catalog in Reverse Order:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*TIjuu2g1Vd0_qi5C1_gCCQ.png" /></figure><h4>✦ Nested for loops</h4><p>A nested for loop is simply a for loop inside another for loop. When you have one loop running inside another, the inner loop completes all of its iterations for every single iteration of the outer loop. This means the inner loop restarts and finishes entirely each time the outer loop takes one step forward.</p><p>Nested loops are essential for working with tabular data, grids, matrices, and any scenario where you need to compare or combine elements from multiple collections. While beginners often learn nested loops by printing star patterns, the real power emerges when you apply them to practical problems like analyzing sales data, managing seating arrangements, or processing spreadsheets.</p><h4>Understanding How Nested Loops Execute:</h4><p>Before diving into real-world examples, understand this fundamental behavior:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Ijnl5DjQjtr9iTsD7hgmA.png" /></figure><ul><li>The outer loop starts with its first value</li><li>The inner loop runs through ALL of its values</li><li>The outer loop moves to its second value</li><li>The inner loop runs through ALL of its values again</li><li>This continues until the outer loop completes</li></ul><p>In other words, if the outer loop has 5 iterations and the inner loop has 10 iterations, the inner loop body executes 50 times total (5 x 10).</p><h3>Nested For Loop Example: The Classroom Seating Chart Example</h3><p>This is the simplest way to understand nested loops. Think of a classroom with rows of desks. Each row contains multiple desks.</p><ul><li>The outer loop represents each row</li><li>The inner loop represents each desk in that row</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wuEufdpeQvB-6NqIleMHFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*NQ-mVAv1dZOfPDC7ZNC0rw.png" /></figure><h4>How This Works Step by Step:</h4><ol><li>The outer loop starts with row_number = 1</li><li>The inner loop runs completely: desk_number = 1, 2, 3, 4</li><li>The outer loop moves to row_number = 2</li><li>The inner loop runs completely again: desk_number = 1, 2, 3, 4</li><li>The outer loop moves to row_number = 3</li><li>The inner loop runs completely one more time</li><li>The outer loop finishes</li></ol><p>Total executions: 3 rows × 4 desks = 12 times the inner loop body runs</p><h4>✦ Python While Loop</h4><p>In simple words, The while loop enables the Python program to<strong> repeat a set of operations while a particular condition is true</strong>. When the condition becomes false, execution comes out of the loop immediately, and the first statement after the while loop is executed.</p><p>A while loop is a part of a control flow statement which helps you to understand the basics of Python.</p><p>We use a while loop when the number of iteration is not known beforehand. For example, if you want to ask a user to guess your luck number between 1 and 10, we don’t know how many attempts the user may need to guess the correct number. In such cases, use a while loop.</p><ul><li><strong>Indefinite Iteration</strong>: An unknown number of iterations. Ask the user to guess the lucky number. You don’t know how many attempts the user will need to guess correctly. It can be 1, 20, or maybe indefinite. In such cases, use a while loop.</li></ul><p>So, when number of iteration is not fixed always use the while loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFgA_6mCbO-SjAI8uEH8qQ.png" /></figure><ul><li>The while statement checks the condition. The condition must return a boolean value. Either True or False.</li><li>Next, If the condition evaluates to true, the while statement executes the statements present inside its block.</li><li>The while statement continues checking the condition in each iteration and keeps executing its block until the condition becomes false.</li></ul><h4>Flowchart of while loop</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/0*mL05BxxQWgE7TxCj.png" /></figure><h4>Infinite While Loop in Python</h4><p>An infinite while loop refers to a while loop where the while condition never becomes false. When a condition never becomes false, the program enters the loop and keeps repeating that same block of code over and over again, and the loop never ends.</p><p>The following example shows an infinite loop:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*btImi3FEsQitIf-yNYkqiQ.png" /></figure><p>If we run the above code block, it will execute an infinite loop that will ask for our names again and again. The loop won’t break until we press ‘Ctrl+C’.</p><p>Let’s see a simple example to understand the while loop in Python</p><p>◾<strong>Example 01: Print numbers less than 5</strong></p><p>In the above example, the while loop executes the body as long as the counter <a href="https://pynative.com/python-variables/">variable</a> is less than 5. In each iteration, we are incrementing the counter by 1. Eventually, the counter variable will no longer be less than 5, and the while loop will stop executing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*QfT6Byn_G9QJf-htZdj9ng.png" /></figure><p>◾<strong>Example 02: Classroom Registration with Maximum Capacity</strong></p><p>Scenario: Register students until classroom is full (max 5 students).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*FYbWQVxHMHLft_YORiBvig.png" /></figure><p>◾<strong>Example 03: Coffee Machine Brewing Cycle</strong></p><p>Scenario: Coffee machine heats water until it reaches optimal temperature (95°C).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*WKvtocHmM3A9vTLvWJPk1w.png" /></figure><h4>✦ Python Nested While Loop</h4><p>A nested while loop is a while loop inside another while loop. The inner loop completes all its iterations for each single iteration of the outer loop.</p><p><strong>Basic syntax of a nested while loop</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*ZKn2pf74yWWxW6XeX-YcEw.png" /></figure><p>◾<strong>Example 01: Bakery Packing Cookies into Boxes</strong></p><p>Scenario: A bakery packs 3 cookies into each box. Multiple boxes are packed until all cookies are used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*gebe0GWIK1h7EKkQxmQ6Cg.png" /></figure><h4>✦ Performance Comparison: while loop vs for-loop</h4><p>In terms of performance efficiency between the for loop and while loop in Python, for loops are generally faster and more memory efficient than while loops because they majorly iterate over the predefined range of values with additional checks. However, if we talk about the while loops, they generally provide more flexibility for the scenarios where you need to iterate over the specific conditions dynamically until that condition is satisfied.</p><p>◾<strong>Example to measure performance benchmarks:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*FD6uEH2u-CUOjQlecjbZfQ.png" /></figure><h3>1.3 Transfer Statements in Python</h3><p>In Python, transfer statements (also known as control flow transfer statements or jump statements) are used to alter the normal flow of execution in loops or functions. The main transfer statements in Python are:</p><ol><li>break</li><li>continue</li><li>pass</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*0xYwgoygqgJKLi-GX9HwGw.png" /></figure><h4>✦ Break Statement in Python</h4><p>The break statement is used inside the loop to exit out of the loop. In Python, when a break statement is encountered inside a loop, the loop is immediately terminated, and the program control transfer to the next statement following the loop.</p><p>In simple words, A break keyword terminates the loop containing it. If the break statement is used inside a nested loop (loop inside another loop), it will terminate the innermost loop.</p><p>For example, you are searching a specific email inside a file. You started reading a file line by line using a loop. When you found an email, you can stop the loop using the break statement.</p><p>We can use Python break statement in both for loop and while loop. It is helpful to terminate the loop as soon as the condition is fulfilled instead of doing the remaining iterations. It reduces execution time.</p><p><strong>Syntax of </strong><strong>break</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*3QqD7L9dc8jR4DMq_p7cqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*X8ExdQ5Uxh1W6-dInYlVdg.png" /><figcaption>Flow chart of a break statement</figcaption></figure><p>◾<strong>Example 01: Using break on for loop in Python — Reading Sensor Data Until a Threshold is Exceeded</strong></p><p>A sensor reads temperature every second. Stop the loop when temperature exceeds 100 degrees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*y50Ia58K98CzAvYQe9x36g.png" /></figure><p>◾<strong>Example 02: Using break on while loop in Python — ATM Withdrawal Attempts</strong></p><p>User has 3 attempts to enter the correct PIN. Break the loop if they succeed earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*kHtLL-BLaSzfASKwqWN_JA.png" /></figure><h4>✦ Continue Statement in Python</h4><p><strong>The </strong><strong>continue statement skip the current iteration and move to the next iteration</strong>. In Python, when the continue statement is encountered inside the loop, it skips all the statements below it and immediately jumps to the next iteration.</p><p>In simple words, the continue statement is used inside loops. Whenever the continue statement is encountered inside a loop, control directly jumps to the start of the loop for the next iteration, skipping the rest of the code present inside the loop’s body for the current iteration.</p><p>In some situations, it is helpful to skip executing some statement inside a loop’s body if a particular condition occurs and directly move to the next iteration.</p><p><strong>Syntax of </strong><strong>continue</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*xVbHGusuF5xtyTkOSL2kCA.png" /></figure><p>◾<strong>Example 01: Using continue for loop in Python — Hotel Room Cleaning Skip Occupied Rooms.</strong></p><p>Housekeeping staff cleans only vacant rooms, skipping rooms with “Do Not Disturb” sign.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*Pi_r7Knujm4rpVzLpzHYFg.png" /></figure><p>◾<strong>Example 02: Using continue on while loop in Python — Data Backup System Skip Locked Files</strong></p><p>Backup system processes files but skips any files that are currently locked or in use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*6aHau98HTiWrZGwAJpBPBw.png" /></figure><h4>✦ Pass Statement in Python</h4><p>The pass is the keyword In Python, which won’t do anything. Sometimes there is a situation in programming where we need to define a syntactically empty block. We can define that block with the pass keyword.</p><p>A pass statement is a Python null statement. When the interpreter finds a pass statement in the program, it returns no operation. Nothing happens when the pass statement is executed.</p><p>It is useful in a situation where we are implementing new methods or also in exception handling. It plays a role like a placeholder.</p><p><strong>Syntax of </strong><strong>pass statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*WP_hxOgmaKrGYZ9R2r6yEQ.png" /></figure><p>◾<strong>Example: Pass statement — Future Age Restriction Check</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*09hzHtwzYU1kFmf_opXSZA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=228f07190892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Programming Basics for Data Science [Part 3: Everything you need to understand about data…]]></title>
            <link>https://medium.com/@saimw1083/python-programming-basics-for-data-science-part-3-everything-you-need-to-understand-about-data-55d6f41ff2aa?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/55d6f41ff2aa</guid>
            <category><![CDATA[lists-in-python]]></category>
            <category><![CDATA[sets-in-python]]></category>
            <category><![CDATA[data-types-in-python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-data-structures]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Wed, 06 May 2026 07:20:59 GMT</pubDate>
            <atom:updated>2026-05-06T07:20:59.490Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python Programming Basics for Data Science [Part 3: Everything you need to understand about data types in Python]</h3><h3>Data Types in Python</h3><p>We come across different types of values in day-to-day life like count of objects which is an integer, weight in kg which is a decimal, name of a person which is a string, etc.</p><p>In Python, data types define a variable’s value, including numbers, strings, or sets. The most commonly used data types are integers(int), floating point numbers(float), string(str), list(list), and dictionary(dict). Python is known for its simplicity and powerful functionality. One of the important features of data type is dynamic typing, which allows variables to change their data type as needed. This flexibility makes Python highly versatile and easy to work with.</p><p>The data types include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykY0QxlpeWa64ScxqGFTuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIKtr3T7qDZQoIc_OqVmlQ.png" /></figure><h3>1. Numeric Data Types in Python</h3><p>Numeric data types in Python can hold numeric values such as integers, decimal numbers(floating numbers), and complex numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KRX5DK-rgL67QbmZemHcw.png" /></figure><ol><li><strong>int</strong>: This represents the integer values like 1,4, 99, etc.</li><li><strong>float</strong>: This is used to store the decimal values like 3.5, 4.0, etc.</li><li><strong>complex</strong>: This stores the complex value with the imaginary part represented with ‘j’, same as in math.</li><li><strong>long</strong>: This class was used to store integers of bigger length. But this does not exist in the Python versions 3.x.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*NewE0Pwsw9fUXiB0miEkCQ.png" /></figure><blockquote>The built-in function ‘type ()’ can be used to find the data type of a variable. We can also use isinstance() to check if the value is of the specified data type or not.</blockquote><h3>2. Boolean ( bool) Data Types</h3><p>Python also provides one built-in data type, Boolean, that gives us two values, True and False. It can take the value of either True or False and is implemented by the class bool. The true expressions will be returned as True by Python, while expressions that are not true will be returned as False.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*NsiJnHAJu52mWY3bTC1rXQ.png" /></figure><p>Comparison Operations of Boolean data types</p><p>Most boolean values are created dynamically when you compare two values. The following operators return a boolean result:</p><ul><li>== (Equal to)</li><li>!= (Not equal to)</li><li>&gt; (Greater than) / &lt; (Less than)</li><li>&gt;= (Greater or equal) / &lt;= (Less or equal)</li></ul><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*Ry8Xoqn82-915qfHPSMOjQ.png" /></figure><h3>3. Sequence Data Types in Python</h3><p>Sequence data types in Python are capable of representing ordered collections of items. They are iterable, support indexing and slicing, and provide multiple manipulation methods. These are the following sequence data types in Python:</p><ul><li>String</li><li>List</li><li>Tuple</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4JVTkkrjvnNL5E-GfrrTYA.png" /></figure><h4>3.1 Python String Data Type</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*S62W418ia6loATWESSgUPQ.png" /></figure><p>Python strings are a combination of letters or characters enclosed in single quotes or double quotes. In Python, there is no character data type. Here, character is also included in the string class. A string of length 1 can be called a character string. We can access individual characters with the help of an index. The str class represents it.</p><ul><li>Creation of String in Python:<br>In Python, a string can be created by placing characters or letters within either single quotes (‘ ‘) or double quotes (” “).</li></ul><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4e7LFzi_iMMFeVvHQHJcSg.png" /></figure><p>Operations on Python Strings:</p><p><strong>[a] Accessing the characters of Python strings using indexes:</strong></p><p>We can access the elements of the strings using indexes. We can use the string name followed by the corresponding index in the square brackets. In Python, the index of the strings starts from 0.</p><p>Example of accessing a character of a string:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*fI5hnHa9if_eZllocx5TVg.png" /></figure><p><strong>[b] Slicing Python string to get substring:</strong></p><p>Slicing is to get more than one character of a string. We do indexing here too. To get the characters from the ‘i’th index to the ‘j’th, excluding the ‘j’th one, we can give the indexing as ‘i:j’.</p><p>Example of slicing a string by using indexes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*DqpZbFLpssOFAGM8BdBeSQ.png" /></figure><p><strong>[c] Concatenation of Python strings:</strong></p><p>We can use the ‘+’ operator to concatenate two or more strings. This appends the next string at the end of the previous string as shown below.</p><p>Example of the concatenation of strings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*cvf_niwK0RfJiaIiYC8ZVg.png" /></figure><p><strong>[d] Immutability property of Python string:</strong></p><p>This is the property of the string that does not allow us to change the characters of the string. Because of this, if we try modifying we get an error as shown below.</p><p>Example to show immutable property of String:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*32DHErARNzAXmPcVVZv8pw.png" /></figure><p><strong>[e] Python String formatting:</strong></p><p>This is a method of combining the constant characters and values of the variables. We have three methods to do so. These are:</p><p>1) % operator<br>2) f-string<br>3) format() method</p><p>Example on string formatting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*IeGmG-YFUEZ-2i3r_r2l8Q.png" /></figure><h4>3.2 Python List Data Types</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*kI5nHEh000RAwtdgyJuJBA.png" /></figure><p>Lists in Python are created using a square bracket [ ]. They can hold various data types, such as numbers, text, or even other lists. Each entry within a list is separated by a comma. Lists allow you to combine multiple items into one collection and give easy access and modification as required.</p><p>Example on creating a Python list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*f5YH3S3OQ7XYJoaIYQ2d8g.png" /></figure><p>Operations that can be done on the list are:</p><p><strong>a. Accessing elements of a list using an index:</strong></p><p>We can access a value of a list by using the index, the location of the value. We can use the list name followed by the corresponding index in the square brackets. The index of the values of a list starts from 0.</p><p>Example on accessing elements of a list using an index:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*LNcioJwVuN_bpR1y50iKpw.png" /></figure><p><strong>b. Slicing list to get a sub list:</strong></p><p>We can slice a list to get multiple values of a list. We can give the indexing as ‘i:j’ to get the values from the index ‘i’th to the ‘j’th, excluding the ‘j’th one.</p><p>Example on slicing list by indexing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*an9K2f5imVITC8dbR9Z-EA.png" /></figure><p><strong>c. Finding the length of a list:</strong></p><p>We can find the length of the list by using the built-in function len(). This takes the input as the list and returns the length as shown below.</p><p>Example on finding the length of a list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*Mm6f_crvlTLFUBRd6XI1cg.png" /></figure><p><strong>d. Changing the elements of the list by reassigning the value:</strong></p><p>We can reassign a value using the index by the following syntax:</p><p>We can also add the values at the rightmost end of the list using the append() method and delete the values at the rightmost end using the pop() function.</p><p>Example of changing a particular element of list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*m-LuJXNNyxT_L6Ap-dcuWQ.png" /></figure><p><strong>e. Looping over a list in Python:<br></strong>We can iterate over every element of a list using the loops. The below example shows an example of iterating using the ‘for’ loop. Here we used the iterator as the variable ‘i’ that goes through each element of the list till it reaches the end.</p><p>Example of iterating over a Python list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*LXsfUEBewsxVxjxoWpj_ZQ.png" /></figure><p><strong>f. Multidimensional lists:</strong></p><p>Lists can be any dimension. An example of a 2D list is:</p><p>Example of creating a multidimensional list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*SYLvKE0EEqaK2Bn6Z5qadA.png" /></figure><h4>Other operations of lists include:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOdB3DzjL1_4cfRENGg4TQ.png" /></figure><h4>3.3 Tuples in Python:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*R2CeqPj4zG3FTaLQw43LUA.png" /></figure><p>In Python, Tuples are a data structure of the sequence type that store a collection of data. Python Tuples have these 5 characteristics.</p><ul><li>ordered</li><li>unchangeable</li><li>immutable</li><li>allow duplicate value</li><li>allow values with <strong>multiple data types</strong></li></ul><p>Creating a tuple is done using the parentheses (()) or the tuple() constructor function.</p><p><strong>Example of creating a tuple and doing operations on it:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*pcN6y9Q8JwmwNDflhR-zTw.png" /></figure><p><strong>a. Accessing the tuple values:</strong></p><p>The operations are the same as in lists except for those which change the values. We can access it using the index.</p><p>Example of doing operations on it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*iDnWAZQIVG-Snrx1glxAKw.png" /></figure><p><strong>b. Immutability of Python Tuples</strong></p><p>But since the tuples are immutable we get an error when we try to change the elements or delete any element.</p><p>Example of doing operations on it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*J-yVUovPeivlAEL7K4Pg6Q.png" /></figure><p><strong>c. Finding the length of Python tuple:</strong></p><p>To find the length we use the built-in function len().</p><p>Example of doing operations on it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*7YeLqyFPu_-TUx3TJNychQ.png" /></figure><p><strong>d. Other operations on Tuples in Python:</strong></p><p>We can also add two tuples or multiply the tuple by an integer. We can do this using the ‘+’ and ‘*’ operators respectively.</p><p>Example of doing addition and multiplication on tuples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*yV1y6YDt53FZljBn4v9W8Q.png" /></figure><p><strong>e. Python Multidimensional Tuples:</strong></p><p>Like we have a multidimensional list, we have multidimensional tuples. These are the tuples with inner elements as tuples. These are also called nested tuples. The below example shows creating multi-dimensional tuple and accessing its elements:</p><p>Example of Python multidimensional tuples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*botYIl3dvKB3EmoMIXKzDQ.png" /></figure><h3>4. Python Dictionaries</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cO2eH3X6FtUgo-_LThIkQA.png" /></figure><p>These are as a set of key-value pairs. This is similar to dictionaries used for knowing the meanings, where unique words/keys are mapped to meanings/values. The keys and values can be of any datatype.</p><p>Example of creating Python dictionary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*1WRNqlTyujrLTt_b9ZrkyQ.png" /></figure><p>We can also create dictionaries from lists or tuples as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*NygTa6lkFE2UtPY-BT7fGw.png" /></figure><h4>4.1 Operations that can be done on Python dictionaries:</h4><p><strong>a. Accessing values using a key element:</strong></p><p>The elements of a dictionary are not ordered, so we cannot index here. But we can use keys to access corresponding values. We can also access it using the get() method.</p><p>Example on accessing a value using key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*V8Zsda5hLEU3PaE5aXrD7A.png" /></figure><p><strong>b. Reassigning values and deleting elements in Python:</strong></p><p>We can reassign a value corresponding to a key by giving the key as the argument.</p><p>The syntax is:</p><p><em>dict_name[key]=new_value</em></p><p>Similarly, we can delete using the pop() function by giving the corresponding key as the argument.</p><p>Example of changing the value of a key element :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*GQeimcN7HdZT98hav2Pr3g.png" /></figure><p><strong>c. Getting all the keys and values as a list:</strong></p><p>We can get all the keys and the values using the keys() and values() functions respectively.</p><p>Example on getting the keys and values as lists:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*8CD9QqFkBIwAE3S-Vf3yZQ.png" /></figure><p><strong>d. Other operations include a dictionary:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7M4rn3p4f2cUZ6l651SZw.png" /></figure><h3>5. Sets in Python</h3><p>Do you remember what a <strong>Set</strong> is from your school days? A set is a <strong>well-defined</strong> group of <strong>distinct</strong> objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*2YpCGnEcSMyzg3XKtrjFdw.png" /></figure><p>A set can be a very useful tool for computer programming. Python has a built-in set type. In this article we will learn about the set data type in python, its operations, complexities and where we can use this type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*N_5AwBxOMn8ZKeAcDrpDeQ.png" /></figure><h4>5.1 What Are The Characteristics Of A Set In Python?</h4><p>Python set has these characteristics:</p><p>1. Creating a set in Python</p><p>Sets have the elements in the curly brackets with each of them separated by a comma. It can contain values of different data types.</p><p>Example of creating a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*NVQkrLTfRiBNnikr8eoEDw.png" /></figure><p>2. Does not allow duplicates:</p><p>One of the properties of a set is not to allow duplicate values. While creating a set if we give a duplicate value, it will occur only once in the set. For example,</p><p>Example of creating a set with duplicate values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*YOpYxHPYBLAfYexy_jX1aw.png" /></figure><p>3. Unhashable elements:</p><p>Though a set is mutable, it cannot have mutable elements like lists, sets, or dictionaries. Therefore, there is no concept of nested sets. So we get an error if we try to create a set with any of these data types as shown below.</p><p>Example of creating a set with mutable elements :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*ugFyi6BnL1kQCIedQer74A.png" /></figure><p>But we can include a tuple in a set as it is immutable. For example,</p><p>Example of creating a set with a tuple:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*E8FGzFDANjJFicXJiw-9TQ.png" /></figure><p>4. Creating an empty set:</p><p>Generally, when we try creating an empty list or tuple or a dictionary, we give only the corresponding brackets. But this is not possible in the case of an empty set. Look at the below example to know the reason.</p><p>Example of creating a variable with curly brackets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*lH4asidWp7IzzQ8ZLoWO-w.png" /></figure><p>Remember even the dictionaries use curly brackets to enclose their elements. So, when we try to give empty curly brackets, it is considered as an empty dictionary.</p><p>Then how do we create an empty set? You will find the answer for this in the next point where we create a set using the set() function.</p><p>5. Creating set using the set() function:</p><p>Another way to create a set is by using the set() function. First let us see the creation of an empty set, which is false in a boolean context.</p><p>Example of creating an empty set using the set() function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*Lq1TsGiKVJ09wLfEt8OWaw.png" /></figure><p>We can give any iterable as an argument to the set(), to create the corresponding set.</p><p>Example of creating a set using the set() function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*4GdCoOxU7DSBpaEyNxQh5g.png" /></figure><p>Observe that the duplicates from the arguments of the set do not occur in the resulting set. Also, see the difference between the creation of a set using curly brackets and using the set() function with a single string.</p><p>Example of creating a set with string:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*a35QtuCLFDHai6V3X1lbng.png" /></figure><p>Interesting result, isn’t it? This is because when we create using the bracket, the string is considered as a single value. But while using the set() function, it is considering the string as an iterable with a collection of characters.</p><h4>5.2 Accessing the values of sets in Python</h4><p>Since sets are not ordered, they do not support indexing. However, we can access the entire set using the set name as shown below.</p><p>Example of accessing the entire set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*gxSShhWVP56D0vReFXkZtg.png" /></figure><p>Observe the set 2 results. We can see that the duplicates got removed and the elements got ordered.</p><p>Let us not keep the doubt of indexing and check that.</p><p>Example of accessing element of a set using indexing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*3cj6fZK92ogO_7F30UgJ6g.png" /></figure><p>We can observe from the error that we cannot use indexing for the sets, which means indexing is not allowed.</p><h4>5.3 Adding Elements and Updating a Set in Python</h4><p>We just saw above that the set does not support indexing. For this reason, we cannot use an index for reassigning a value of a set. But don’t worry, because we have concerned functions to update and add values. We will discuss these functions in this section.</p><h4>1. Python add():</h4><p>We can use this function to add a value to the set. For example,</p><p>Example of adding a value to a set using add():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*T0u_VyU3jVhE2ImJn4mDqQ.png" /></figure><p>We can see that on adding element 2, the set got rearranged to maintain the order. If the added element is less than all the elements of the set, then all the elements have to be shifted to the right. This makes the complexity O(n) (Order of n). But the average case can be taken as O(1).</p><p>However, the set does not get affected when we try adding an element of the set.</p><p>Example of adding an existing value to a set using add():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*iOs9f0xynayhsOR9lLiCTw.png" /></figure><h4>2. Python update():</h4><p>We use this function generally to add multiple elements to the set. We can give these elements lists or tuples too. If we give them as normal data types we get an error. As usual, if we add duplicates, they are ignored.</p><p>Example of adding values to a set using update():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*skDiuU2ch7cY-9PcRbhlGQ.png" /></figure><h4>5.4 Deleting values from a list in Python</h4><p>Again we have a couple of in-built functions to delete the values of a set and we cannot use indexing.</p><h4>1. Python discard():</h4><p>This function deletes the value given as an argument. It doesn’t give an error if the argument is not present in the set, it just keeps the set intact.</p><p>Example of deleting values to a set using discard():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*DAg5GSqORdehbg-gSf8fow.png" /></figure><h4>2. Python remove():</h4><p>This function is similar to discard and deletes the value given as an argument. The only difference is that it gives an error if the argument is not present in the set.</p><p>Example of deleting values to a set using remove():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*HTMjwuQYGkGht_flNjtPmw.png" /></figure><h4>3. Python pop():</h4><p>This function pops a random element from the set. Since we cannot index in the case of sets, this function does not take any argument.</p><p>Example of deleting values to a set using pop():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*OOy6CjmBcPIDA4_TqPuy9Q.png" /></figure><h4>4. Python clear():</h4><p>This function removes all the values of a dictionary. But it keeps the instance of the set and when called gives an empty set.</p><p>Example of deleting values to a set using clear():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*mXechomknRRPhTo5WZsZJA.png" /></figure><h4>5.5 Functions on sets in Python</h4><p>There are many functions on sets that we can apply to get some information from the set. We will discuss them in this section.</p><h4>1. Python len():</h4><p>The function len() finds the length of the set, that is, the number of elements of a set. For an empty set, the length is 0.</p><p>Example of using the len():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*NQgTc66sTW5akJTzovrG3w.png" /></figure><h4>2. Python max():</h4><p>The function max() finds the largest element/ the maximum of the set if all the elements belong to the same category of values.</p><p>If they don’t for example if the set has a mixture of strings and numbers. And if we try to find the max, we get an error as strings and numbers cannot be compared.</p><p>Example of finding the max():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*i4d92EhcB3h_CL9v5V5bog.png" /></figure><h4>3. Python min():</h4><p>The function min() finds the smallest element/ the minimum of the set if all the elements belong to the same category of values.</p><p>If they don’t belong to the same type, for example, if the set has a mixture of strings and numbers. And if we try to find the max, we get an error as strings and numbers cannot be compared.</p><p>Example of finding the min():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*uvJOFIwbujmwHeY_nqXv6g.png" /></figure><h4>4. Python sum():</h4><p>The function min() finds the smallest element/ the minimum of the set if all the elements are numbers.</p><p>If they don’t belong to the other data type, like strings, we get an error as strings cannot be summed.</p><p>Example of finding the sum():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*xk2Iz07JxhA72cTnZgcarw.png" /></figure><h4>5. Python all():</h4><p>This function checks if all the elements of the set are not empty or 0 or False and returns either True or False. It returns False if any of the elements is empty or 0 or False. It can work with a set of varied data types.</p><p>Example of using the all() function on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*-pz63Uq3wVnZGxwzgZziVQ.png" /></figure><h4>6. Python any():</h4><p>This function checks if any of the elements of the set are not empty or 0 pr zero. And returns either True or False. It returns False only if all of the elements are empty or 0 or False. It can work on any tuple.</p><p>Example of using the any() function on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*lc6IIl0qhNiFrhXNB4gRkg.png" /></figure><h4>7. Python sorted():</h4><p>This function returns the version of the set in the form of a list with all elements arranged in increasing order if all values belong to the same data type. This function does not affect the order of elements in the tuple, it only returns the arranged version.</p><p>If we try to apply the sorted() on a set with different data types, we will get an error. This is because the values of different data types cannot be compared.</p><p>Example of using the sorted() function on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*rrIE9PSKvqoxosnUyJ8f-A.png" /></figure><h4>8. Python enumerate():</h4><p>This function returns the enumerated object of the set and contains the value and index of the set as a pair. These can work on a set with aby data type elements.</p><p>Example of using the enumerate() function on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*8-fLN82BHUSyL3J20Lm57A.png" /></figure><h4>5.6 Methods on Sets in Python</h4><p>We have discussed some methods in the sections on adding, updating, and deleting values in the set. Besides these, we have different methods we can perform on the set. We will cover them in the section.</p><h4>1. Python union():</h4><p>This method returns the values of both sets, ignoring the duplicates. The union() is similar to doing the or (|) operation on the sets. Time Complexity is O(len(set1) + len(set2)) where set1 and set2 are the two sets whose union is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*Lhof4DPEo6I0cLfS.jpg" /></figure><p>Example of doing the union() on two sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*bSDMBWrdyz8HBk80EYT8Og.png" /></figure><p>We can do these with more than one set too, by giving more than one set as the arguments to the function or by using more than one set operated by ‘or’.</p><p>Example of doing the union() on multiple sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*Kloa2TViiL95ZXHVOg8yyg.png" /></figure><p>The only difference is that we can use the union() to compare a set and a tuple. But this is not possible with the or operation.</p><p>Example of doing the union() on a set and a tuple:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*3EGt0JcUtMwZLe4q_poysQ.png" /></figure><h4>2. intersection() in Python:</h4><p>This method returns the values common to both sets. The intersection() is similar to doing the and (&amp;) operation on the sets. Time Complexity is O(min(len(set1) , len(set2))) where set1 and set2 are the two sets whose union is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*g4SnBS0TxcpM-WSq.jpg" /></figure><p>Example of doing the intersection() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*IS_yHTGQID1-VaojxlbWqw.png" /></figure><p>Similar to the union(), we can use an intersection with a tuple and a dictionary. We can also use it on multiple sets as shown below.</p><p>Example of doing the intersection() on multiple sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*ZTX66TYCKJT01RwSs2z0Ug.png" /></figure><h4>3. difference() in Python:</h4><p>This method returns the values in the first set that are not there in the second one. The intersection() is similar to doing the minus(-) operation on the sets. Time Complexity is O(len(set1)) where set1 and set2 are the two sets whose union is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*GSQBHFY81s8c3fQY.jpg" /></figure><p>Example of doing the difference() on a sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*OJpubHGjG1QYq1jB4qoO_Q.png" /></figure><p>We can use an intersection with a tuple and a dictionary. We can also use it on multiple sets as shown below.</p><p>Example of doing the difference() on multiple sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*JsCCafl2pSJn_HvugODdvQ.png" /></figure><h4>4. symmetric_difference() in python:</h4><p>This method returns the values that are not common to both sets. The intersection() is similar to doing the xor(^) operation on the sets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*3i2RwW8fxBnx9uXC.jpg" /></figure><p>Example of doing the symmetric_difference() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*LkMaCl2rliWKuJAdlqsYkQ.png" /></figure><p>We can use an intersection with a tuple and a dictionary. We cannot also use it on multiple sets with the symmetric_difference(), but we can use it with the ^ operator as shown below.</p><p>Example of doing the symmetric_difference() on multiple sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*m2muGiTMHGyy0ndd-0-VVA.png" /></figure><h4>5. isdisjoint() in Python:</h4><p>This function returns a true value if it doesn’t contain any intersection values or doesn’t have any common elements. If this condition is generally satisfied, then it returns true value. Else, it will return false. Let’s understand it with an example,</p><p>Example of doing the isdisjoint() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*o21ve5QfgxlMp0qBYcKUKg.png" /></figure><h4>6. issubset() in Python:</h4><p>This function is True if the set is the subset of the one in the brackets, that is the set in the bracket has all the elements of the other one. This is similar to checking with the operator ‘&lt;=’. If this condition is satisfied then set2 is said to be the subset of set1.</p><p>If the set2 and set2 also satisfy the condition set2&lt;set1, then the set2 is called the proper subset of set1. For example,</p><p>Example of doing the issubset() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*t1IC84k7_x8aYoJxk5eMqg.png" /></figure><h4>7. issuperset() in Python:</h4><p>This function is True if the set is the super of the one in the brackets, that is the set has all the elements of the one in the brackets. This is similar to checking with the operator ‘&gt;=’. If this condition is satisfied then set2 is said to be the superset of set1.</p><p>If the set2 and set2 also satisfy the condition set2&gt;set1, then the set2 is called the proper superset of set1. For example,</p><p>Example of doing the issuperset() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*TFLEfBlnye4ICctHfxuo8w.png" /></figure><h4>8. intersection_update() in Python:</h4><p>This function finds the intersection of the two sets and replaces the first set with the intersection.</p><p>Example of doing the intersection_update() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*bPrWmspM8FK5KkK_f_usJw.png" /></figure><h4>9. difference_update() in Python:</h4><p>This function finds the difference of the second set from the first and replaces the first set with the difference.</p><p>Example of doing the difference_update() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*mKHkYvwxNIUpWxrc2p36jA.png" /></figure><h4>10. symmetric_difference_update() in Python:</h4><p>This function finds the non-common values from both sets and replaces the first set with the result. For example,</p><p>Example of doing the symmetric_difference_update() on sets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*aKIetIStIUWuHwReL6paUA.png" /></figure><h4>11. copy() in Python:</h4><p>This function creates a shallow copy of a set, that is, creates the copy of the set and adds the reference to the same memory.</p><p>Example of making a copy of a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*PYBFit8Xdk9oxNgulOiOSQ.png" /></figure><h4>5.7 Operations on a set in Python</h4><p>We will talk about the operations that we can do on the sets.</p><h4>1. Membership</h4><p>There are two membership operators, namely, ‘in’ and ‘not in’. These are used to check if a value exists in the set. The function ‘in’ gives True if it exists else False. The ‘not in’ works the opposite way of ‘in’.</p><p>Example of doing membership operations on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*8QEHys118NNkY4OSfNJW1Q.png" /></figure><h4>2. Python Looping</h4><p>We can go through each element of the set using the loops. The ‘for loop’ is the most common one.</p><p>Example of iteration on a set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*cx96Lpz_ROr7nnz2ZUtHcQ.png" /></figure><h4>5.8 Frozen Set in Python</h4><p>The frozen set is the data type that has the same aspects of a set, except that these are immutable. An example of creating a frozen set is shown below.</p><p>Example of creating Python frozen set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*Ek3OXKbJvESYumuTrqHFfA.png" /></figure><h4>1. Keys in Python dictionary:</h4><p>Since these are immutable, they can be used as the keys of dictionaries.</p><p>Example of creating frozen set in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*HqGErNHX9bawU0QDs_OMeg.png" /></figure><h4>2. Python Built-in Functions and Methods:</h4><p>It supports all the functions and methods of a set which try not to modify the set. These include len(), max(), min(), sum(), all(), any(), sorted(), copy(), difference(), union(), intersection(), symmetric_difference(), isdisjoint(), issuperset(), and issubset(). If we try applying the other modifying functions, we get an error.</p><p>Example of using built-in functions on frozen set in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BconW3nOvm0iPIP3yCgV6w.png" /></figure><h4>5.9 Comparison of Set with Other Data Types</h4><h4>1. Set vs List</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*NXJe5Dav4k_2YpmNUCSESg.png" /></figure><h4>2. Set vs Tuple</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*zEmY2S3v9mwUHGTBrADaRg.png" /></figure><h4>3. Set vs Dictionary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*iIjDNin0t1c3-6BDAKFFkw.png" /></figure><h3>6. Difference Between Mutable And Immutable Data Types in Python</h3><p>Given below are the key differences between the mutable and immutable data types in Python programming:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*zje29VtferFxWTk-0hw01g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55d6f41ff2aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Python Basics for Data Science [Part 2: Variables, Data Types and Operators]]]></title>
            <link>https://medium.com/@saimw1083/introduction-to-python-basics-for-data-science-part-2-variables-data-types-and-operators-b539daace374?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b539daace374</guid>
            <category><![CDATA[python-operator]]></category>
            <category><![CDATA[data-types-in-python]]></category>
            <category><![CDATA[python-basics-course]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 07:57:17 GMT</pubDate>
            <atom:updated>2026-04-28T07:57:17.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9Jp_hU8UPMl3NS6mwEcKg.png" /></figure><h3>2.1 Comments in Python</h3><p>When writing code in Python, it’s important to make sure that your code can be easily understood by others, say by your friend who wants to see your code.</p><p>Python ignores everything after the hash mark (#) and up to the end of the line. You can insert them anywhere in your code!</p><p>A shortcut for adding comments is by using <em>CTRL + /</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*cbFdVTPeZj4bjgnd.png" /></figure><h3>2.2 Variables</h3><p>A variable can be considered as a storage container for data.</p><ul><li>Every variable will have a name.</li><li>It is a good way to store information while making it easy to refer to that information in our code later.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*LyoxETHFcM227Y_4.png" /></figure><ul><li>For instance, instead of working with the number 3.14, we can assign it to a variable pi and use it as many times as we want in our code (wherever required).</li><li>The equal sign (=) is used to assign values to variables.</li><li>The syntax for assigning values to a variable is as follows: Variable name = value or information.</li></ul><p>Example:</p><p>x = 5</p><p>y = “John”</p><h3>2.3 Input and Output in Python</h3><h3>✦ Print Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/0*oJkgZv-oThtKFefN.png" /></figure><h3>✦ Input Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*PpGMmbYvDvzdqw6s.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/0*EffrRd6YrAlZ0qfJ.png" /></figure><h3>2.4 Operators in Python</h3><p>Operators are used to perform simple operations such as additions, comparisons etc on variables and values.</p><p>Python supports the following types of operators, we will be looking at some of the commonly used operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/0*4JvtqXvYMp__XNUi.png" /></figure><h3>✦ Arithmetic Operators</h3><p>We can perform some basic arithmetic operations such as addition, subtraction, multiplication, etc. using Python.</p><p>Example:</p><p>x = 2<br>y = 3<br>x + y # addition<br>x * y # multiplication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*D_HlbyMleRRBeU8x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*XI_NOTqaYvkW0w0s.png" /></figure><h3>✦ Comparison Operator</h3><ul><li>These are used to compare two values</li><li>Gives a Boolean result (True/False)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/0*8HEB5_97gu2e0arM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*kqz08GRs6cK6HpoK.png" /></figure><h3>✦ Logical Operator</h3><ul><li>Logical operators are used to combine conditional statements</li><li>Gives a Boolean result (True/False)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/0*X5qOjwTwzB26u_OY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*qQxw9W4JQCUxPw6M.png" /></figure><h3>✦ Assignment Operators: Storing and Updating Values</h3><p>The next major category is the assignment operator in Python. These operators are used to assign or update the value of a variable. The most basic assignment operator is the equals sign (=), which you’ve already seen. It simply stores the value on the right in the variable on the left.</p><p>Beyond the simple equals sign, Python provides several compound assignment operators. These are convenient shorthands that combine an arithmetic operation with an assignment. For example, instead of writing x = x + 10, you can simply write x += 10. This makes your code cleaner and more concise.</p><p>Let’s look at the primary assignment operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*Wrzbg0q4FbnT7Evb4zJ8Sw.png" /></figure><p>Here’s how you would use these operators in a real script. We’ll initialize a variable and then update it using different compound operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*T0FF_pzyQQq-gEVtys93zw.png" /></figure><h3>✦ Membership Operators</h3><p>These are very intuitive and useful. Membership operators test whether a value is found within a sequence, like a string, list, or tuple.</p><ul><li><strong>in</strong>: Returns True if a value is found in the sequence.</li><li><strong>not in</strong>: Returns True if a value is <em>not</em> found in the sequence.</li></ul><p>The list of membership operators that are present in Python is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-aQypMeGE5BCoWzVWOURg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*x7WPi3hQzNFkS0-x57wVbA.png" /></figure><h3>✦ Identity Operators</h3><p>Identity operators compare the memory location of two objects, not just their values. This is a subtle but critical difference from the == operator.</p><ul><li><strong>is</strong>: Returns True if two variables point to the <em>exact same object</em> in memory.</li><li><strong>is not</strong>: Returns True if two variables point to <em>different objects</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCLSdaPNbgOXK8pVBm4NIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*ptliY1FZKpNFBfjOqO2IzA.png" /></figure><h3>✦ Bitwise Operators</h3><p>You would have heard of operators like addition, subtraction, etc. Wondering what these “Bitwise Operators” are?</p><p>These are also symbols performing modifications on numbers, but at a low level called the Binary system. All the operations done on computers are transformed to this system to make the computers understand. Want to explore more about it? Let’s not wait and begin.</p><h3>Overview on Binary System and Bits</h3><p>Before talking about the binary operators, first, let’s discuss the binary system and bits. We are familiar with the decimal system where we have a base as 10, i.e., every digit is multiplied with the 10 to the power of the digit’s place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*_pBzGpnrEvvfKXm5.jpg" /></figure><p>Similarly, the binary system has a base as 2 and thus has only 0s and 1s. The below picture gives an example of a binary number and its decimal value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*uIYZAlrvmTHbEyBr.jpg" /></figure><p>In Python, the binary equivalents are shown using the bin() function. The binary numbers in Python start with ‘0b’ with the actual number as a continuation.</p><p>Example of finding binary number using bin():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*BZFeam4Wl5H84M9Enw9HPQ.png" /></figure><p>Bit (Binary digit) represents each digit of a binary number. In the above example, the binary number of 6 has 1,1, and 0 are bits. Here we got these bits because<br>1*(22) + 1*(21)+0*(20)<br>=4+2+0<br>=6</p><p>Example of finding binary number using bin():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*Li6n4YQyYqLQ5tMKFFoaFg.png" /></figure><p>In this example, the bits are 1, 1, 0, 0, and 1. These represent 25 in the following way,<br>1*(24) + 1*(23)+0*(22)+0*(21) + 1*(20)<br>=16+8+0+0+1<br>=25</p><h3>Bitwise Operators in Python</h3><p>Bitwise operators perform operations on the bits, rather than on the number as a whole. And they give the new number as the result. In Python, these operators work on integers. We have the following binary operators:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*4wr1QpgqGoSRck0ecpgEqw.png" /></figure><h4>1. Bitwise AND Operator (&amp;) in Python</h4><p>If we have two statements joined by ‘and’, then it means that both statements have to be ‘True’ for the whole logic to be true. Similarly, if the corresponding bits are 1 only then the logic will be 1 using an operator. See the below example and table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oB2Qu5vuflvjRMJV.jpg" /></figure><p>Example of <strong>AND</strong> Operation in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*LiVixKNeltotuEk7ahmkBg.png" /></figure><h4>2. Bitwise OR Operator (|) in Python</h4><p>When two statements are joined by or, then the overall logic will be true if any of the two is true. The work of the bitwise OR is also the same. It gives output as 1 when either of the bits is 1. For a further understanding look at the below images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sa0h44zm88g39V4g.jpg" /></figure><p>Example of <strong>OR</strong> operator in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*LHGnpZmnk9ABFGYpcERGJA.png" /></figure><h4>3. Bitwise XOR Operation (^):</h4><p>This operation might be new for you guys. This operates on two numbers. It gives 1 when the bits are different and gives 0 when both the bits are either 0 or 1. See the following images for getting the concept clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_IrEfE_r3nlD6Uj8.jpg" /></figure><p>Example of <strong>XOR</strong> operation in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*GWGyAQTS093eyDW24iBBxg.png" /></figure><h4>4. Bitwise NOT Operator (~):</h4><p>This operator works on a single number and inverts all the bits. Then gives the output as the resultant new number. This works like a negation of a statement. Refer to the below pictures for understanding more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zET6foB9nC81wq-y.jpg" /></figure><p>It is also called one’s complement. Because it inverts the bits. It is important to observe that the NOT of a number n gives -n-1 as the result.</p><p>Example of <strong>NOT</strong> Operation in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*X_JGDgNF1dgb9AC09_bwpQ.png" /></figure><h4>5. Bitwise Left Shift Operator (&lt;&lt;):</h4><p>This operator shifts the bits of a number to the right and fills the voids at the right end by 0. The shifting is done by the number of places specified.</p><p>Shifting the digits by one place to the left results in the doubling of the number. Similarly, increasing the number of shifts results in a higher power of double</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*dLCNaaFT0A98VsQ6.jpg" /></figure><p>Example of the <strong>left shift</strong> in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*o17FOVy7hN7-c9mhP_PoZQ.png" /></figure><h4>6. Bitwise Right Shift Operator (&gt;&gt;):</h4><p>It shifts the bits of a number to the right by the specified number of places. And also fills the voids at the left end with zeros.</p><p>This operation halves the numbers on shifting by one place. If shifter by more than 1 place, results in the quotient obtained by dividing the number with two to the power of places</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*YOzH5mI3kpYpCn9d.jpg" /></figure><p>Example of the <strong>right shift</strong> in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*-jSDiF6OAPBB4ZKN4s9Wxw.png" /></figure><h3>✦ Precedence of Operators in Python: The Order of Operations</h3><p>When you have multiple operators in a single expression, how does Python know which one to perform first? It follows a set of rules called operator precedence. This is similar to the PEMDAS/BODMAS rule you learned in math class (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction).</p><p>Understanding the precedence of operators in Python is crucial for writing correct and bug-free code. An expression like 10 + 5 * 2 is not evaluated left-to-right. Python knows that multiplication has higher precedence than addition, so it calculates 5 * 2 first, and then adds 10 to get 20.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*IhPVm9n2XCGRrjDwD9JWvQ.png" /></figure><p>The table below shows the order of precedence for the most common operators, from highest to lowest.</p><h3>2.5 Conclusion</h3><p>Mastering operators is non-negotiable for any aspiring Python developer. They are the core syntax that allows you to manipulate data, control program flow, and implement logic. From the simple addition of two numbers to combining complex conditional checks, every line of functional code you write will rely on them.</p><p>In this guide, I have explored all the major types of operators in Python, including Arithmetic, Assignment, Comparison, Logical, and more specialized ones. I also demystified the precedence of operators in Python, giving you the knowledge to write predictable and accurate code. By practicing with these fundamental tools, you are building a solid foundation for your entire Python programming journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b539daace374" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Python Basics for Data Science [Part 1: Introduction to Python]]]></title>
            <link>https://medium.com/@saimw1083/introduction-to-python-basics-for-data-science-part-1-introduction-to-python-87a2c2d33e50?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/87a2c2d33e50</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 13:21:02 GMT</pubDate>
            <atom:updated>2026-04-27T13:21:02.303Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction to Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*SWyLxiCE0cAJh2PtD6-Wcw.avif" /></figure><h3>1.1 What is Python?</h3><p>Python is one of the most popular programming languages in the world. It gained prominence owing to its simplicity and ease of use. Its syntax is very similar to english language.</p><p>It is an open source free for use tool and has a vast community that contributed over 70K+ libraries. These rich set of libraries makes coding easy for developers and data scientists. Often libraries replace long codes with fewer lines of code.</p><h3>1.2 Why Python for Data Science?</h3><ul><li>Free and open source</li><li>Great community</li><li>Plenty of libraries for Data Science &amp; Machine Learning</li><li>Easy and intuitive to use</li></ul><p><strong>Note:</strong></p><ul><li>Data Science is not about programming languages/tools such as Python, R, Excel, Jupyter Notebook, Google Colab, etc</li><li>Data Science is about using the above tools and techniques, and, if required, inventing new tools and techniques, to solve a problem using “data” in a “scientific” way.</li></ul><h3>1.3 What is Google Colab and Colab Notebook</h3><p>Now that we know the importance of Python in Data Science, let’s try to understand the tools that we need to use to run Python for Data Science tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*XwPJrdxmaFI_FwiyrGGEgw.jpeg" /></figure><p>One of the popular toolkits that data scientists use to run their Python scripts is an interactive notebook. There are various ways in which you can setup an interactive notebook. In this module, we will learn one them, i.e., how to setup and use Google Colab.</p><h3>✦ What are Interactive Notebooks?</h3><ul><li>We are humans and always need user-friendly applications. Notebooks are typically used by data scientists for quick exploration tasks and easy-to-use interactive data science environments.</li></ul><h3>✦ Google Colab — Online Environment to Run Python Code</h3><ul><li>Google colab is the simplest way to setup an interactive notebook environment to perform your data science tasks.</li><li>The environment offers you up to 12 GB RAM/GPU etc for free and 100 GB storage.</li><li>You don’t need to worry about installing a bulky python application on your laptop/computer</li><li><strong>Link to access Google colab:</strong> <a href="https://colab.research.google.com/">https://colab.research.google.com/</a></li></ul><h3>1.4 What is Anaconda and Jupyter Notebook</h3><p>You know by now Python is a programming language. Now what is Anaconda?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*x3DyRfx3l9KsmuCJjGyQkA.png" /></figure><ul><li>Anaconda is a free and open-source distribution of Python. In a nutshell, it makes it easy for you to run Python code on your laptop/computer.</li><li><strong>Again, why Anaconda?</strong> - Well, we are humans and we always want user-friendly applications. And that’s what Anaconda does for you. It offers a powerful tool called “Jupyter notebook” which is an easy-to-use and interactive Python environment for data science.</li></ul><h3>1.5 Installation of Python and Anaconda</h3><h3>✦ For Windows 10/11</h3><ul><li>Step1: Install Python</li><li><a href="https://www.python.org/downloads/">Direct download link</a></li><li>Step 2: Download and install Anaconda <a href="https://docs.anaconda.com/anaconda/install/windows/">here</a>.</li></ul><h3>✦ For Other OS</h3><ul><li><a href="https://docs.anaconda.com/anaconda/install/mac-os/">macOS</a></li><li><a href="https://docs.anaconda.com/anaconda/install/linux/">Linux</a></li></ul><h3>✦ Now Let’s Open Anaconda Navigator</h3><ul><li>Once you install and open Anaconda, you will see the below screen.</li><li>Click “Launch” under Jupyter Notebook in Anaconda Navigator in order to open a notebook in your default web browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vgargT6yMgbTD9q2.png" /></figure><h3>✦ Jupyter Interface</h3><ul><li>This is how the basic Jupyter interface looks like!</li><li>No files might be displayed if your folder is empty.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_4mlaMNlaPPnNwuD.png" /></figure><h3>✦ Create a New Notebook</h3><p>To create a new notebook, go to New at the top right corner and select Notebook — Python 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/0*JKV5dCk3hydLoWqN.png" /></figure><h3>1.6 How to add and execute code in Jupyter Notebook</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgxgARwAOapw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgxgARwAOapw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgxgARwAOapw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa7591530f402e4565f680ad82377418/href">https://medium.com/media/fa7591530f402e4565f680ad82377418/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87a2c2d33e50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t Waste Lakhs! The Smart Bangladeshi’s Guide to Picking the Right MacBook.]]></title>
            <link>https://medium.com/@saimw1083/dont-waste-lakhs-the-smart-bangladeshi-s-guide-to-picking-the-right-macbook-d3f5c382c6d8?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f5c382c6d8</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[laptop]]></category>
            <category><![CDATA[apple-macbook]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 08:27:54 GMT</pubDate>
            <atom:updated>2025-07-21T08:27:54.589Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>1. Introduction: The MacBook Maze in Bangladesh</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*ZrK0X2ZfqvqQXELHFi2NPw.jpeg" /></figure><p>In Bangladesh, navigating the Apple MacBook lineup can feel like solving a complex puzzle. With multiple models, each boasting distinct features and price points, many buyers find themselves overwhelmed. The confusion often stems from a lack of clear information about the differences between models like the MacBook Air and MacBook Pro, or even within the Pro lineup itself. This can lead to costly mistakes — purchasing a model that’s either too powerful (and expensive) for your needs or underpowered for your tasks. For instance, a student might overspend on a high-end MacBook Pro when a MacBook Air would suffice, while a professional might struggle with an Air for demanding tasks like video editing. This guide aims to provide clarity, offering a detailed yet accessible roadmap to help Bangladeshi buyers choose the perfect MacBook with confidence.</p><h3><strong>2.</strong> <strong>Core Philosophy: Why MacBooks Are Different</strong></h3><p>MacBooks stand out in the crowded laptop market due to Apple’s unique approach to hardware and software integration. Here’s what sets them apart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*jOgg_38yJ_Z6dIBIE4M63A.jpeg" /></figure><h4>✦ <strong>Apple Silicon: The Heart of the Difference</strong></h4><p>At the core of every modern MacBook is <strong>Apple Silicon</strong>, specifically the M-series chips. As of July 2025, the latest is the <strong>M4 chip</strong>, powering the MacBook Air and MacBook Pro models. These chips, built on Arm architecture, deliver exceptional performance and energy efficiency. Compared to traditional Intel-based laptops, M4-powered MacBooks offer faster processing, better graphics, and longer battery life, often exceeding 18 hours on a single charge. This efficiency is particularly valuable in Bangladesh, where power outages can make battery life a critical factor.</p><h4>✦<strong> macOS vs. Windows: A Philosophical Divide</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*TmZNEjlh9kl9zbQ0_x7uCg.png" /></figure><h4>✦ <strong>The Apple Ecosystem Advantage</strong></h4><p>For users who own an iPhone or iPad, the Apple ecosystem offers unmatched convenience. Features like</p><p><strong>Continuity</strong> (e.g., copying text on your iPhone and pasting it on your Mac), <strong>Handoff</strong> (starting a task on one device and finishing it on another), and <strong>AirDrop</strong> (fast file sharing) make multitasking effortless.</p><p>In Bangladesh, where many professionals and students use multiple Apple devices, this ecosystem can significantly boost efficiency.</p><h3><strong>3.</strong> <strong>Decoding the MacBook Lineup: Air vs. Pro</strong></h3><p>Apple’s MacBook lineup is divided into two main categories: <strong>MacBook Air</strong> and <strong>MacBook Pro</strong>. Each serves distinct user needs, and understanding their differences is crucial for making the right choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*ojKRUdF-6DbcAVTAgwj2kg.png" /></figure><p><strong>Note</strong>: As of July 2025, MacBook Pro models use M4, M4 Pro, and M4 Max chips, with M5 models expected in 2026.</p><h3><strong>4.</strong> <strong>Understanding the Tech: MacBook Mechanisms Explained Simply</strong></h3><p>To choose the right MacBook, it’s helpful to understand the technology powering these devices.</p><h4>✦ <strong>M1, M2, M3, M4 Generations</strong>:</h4><figure><img alt="MacBook Generations Comparison (M1 to M4)" src="https://cdn-images-1.medium.com/max/739/1*vJGDis6_gXLFBLt2Y6U2ZQ.png" /><figcaption>MacBook Generations Comparison (M1 to M4)</figcaption></figure><h3><strong>5.</strong> <strong>Bangladesh-Specific Buying Considerations</strong></h3><p>Buying a MacBook in Bangladesh requires careful consideration of local factors like pricing, availability, and support.</p><h4><strong>Price Realities:</strong></h4><p>✦<strong> Premium Pricing</strong>: MacBooks are expensive due to import duties and taxes. For example, the MacBook Air M4 starts at ~1,23,000 BDT, while high-end MacBook Pro models can reach ~7,60,000 BDT.</p><p>✦<strong> Long-term Value</strong>: MacBooks retain value due to their durability, performance longevity, and strong resale market. They can last 5–7 years with proper care, making them a worthwhile investment.</p><p>✦ <strong>Price Brackets (as of July 2025 for M4 only)</strong>:</p><ul><li>MacBook Air M4 (13-inch): ~1,23,000 BDT</li><li>MacBook Air M4 (15-inch): ~1,43,000 BDT</li><li>MacBook Pro 14-inch M4 Pro: ~2,20,000 BDT</li><li>MacBook Pro 16-inch M4 Pro: ~2,50,000 BDT</li><li>MacBook Pro M4 Max (high-end): Up to ~7,60,000 BDT</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lM2j0up3gAutYv_4FA7C2A.png" /></figure><h4>✦ <strong>Availability &amp; Authorized Seller:</strong></h4><p><strong>Where to Buy</strong>: Purchase from authorized resellers like:</p><ul><li><strong>Star Tech</strong> (<a href="https://www.startech.com.bd/">www.startech.com.bd</a>)</li><li><strong>RYANS</strong> (<a href="https://www.ryans.com/">www.ryans.com</a>)</li><li><strong>Vertech</strong> (<a href="https://www.vertech.com.bd/">www.vertech.com.bd</a>)</li><li><strong>Dazzle</strong> (<a href="https://www.dazzle.com.bd/">www.dazzle.com.bd</a>), etc..</li></ul><p>Note that, avoid unofficial sellers, as they may offer lower prices but lack warranty and support, risking counterfeit or refurbished units.</p><h4>✦ <strong>Support &amp; Repairs</strong></h4><ul><li><strong>Authorized Service Providers (ASPs)</strong>: Apple has ASPs in Bangladesh for official repairs, ensuring genuine parts and trained technicians.</li><li><strong>AppleCare+</strong>: This extended warranty covers accidental damage and can save on costly repairs (e.g., screen replacement ~20,000–30,000 BDT). It’s highly recommended for peace of mind.</li><li><strong>Local Repair Shops</strong>: While cheaper, they may use non-genuine parts, potentially voiding warranties or causing issues.</li></ul><h3><strong>6.</strong> <strong>Choosing YOUR Perfect MacBook: A Bangladeshi Buyer’s Decision Framework</strong></h3><p>Follow these steps to select the ideal MacBook for your needs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryrwMpVJ6evhvHodhhQIrA.png" /><figcaption>Steps to select the ideal MacBook for your needs Framworks</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LV21RtJ8y0bPrViiaqRi_w.png" /><figcaption>Which MacBook Should I choose?</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*EJMPz1vT9HPwkxGjRM8FSA.png" /><figcaption>Based on common user-types recomended Macbook model table</figcaption></figure><h3><strong>7. Conclusion</strong></h3><p>Choosing the right MacBook in Bangladesh doesn’t have to be overwhelming. By understanding the differences between the MacBook Air and MacBook Pro, the power of Apple Silicon, and local factors like pricing and support, you can make an informed decision. Whether you’re a student needing a portable laptop for university or a professional tackling demanding creative projects, I recommend the MacBook Air M4 16GB RAM with 512GB SSD fits your needs and budget. At the end of this article, I hope this guideline will find your perfect MacBook match.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f5c382c6d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning 101: A Detailed Beginner’s Guide to the Future]]></title>
            <link>https://medium.com/@saimw1083/machine-learning-101-a-detailed-beginners-guide-to-the-future-7d167a700c8a?source=rss-7aca7b13bcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d167a700c8a</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Khondokar Saim]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 15:48:53 GMT</pubDate>
            <atom:updated>2025-06-24T15:48:53.687Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6NbksIix9_6qOs9ZTj7Bw.png" /></figure><p>Machine learning (ML) is an exciting and powerful technology that is changing the world we live in. It’s behind things like Netflix recommendations, self-driving cars, and even the way social media platforms show you posts. ML is a part of artificial intelligence (AI), which helps computers learn from data and make decisions without needing detailed instructions. This guide will explain what machine learning is, how it works, why it’s important, and the different types and tools used in the field.</p><h3>1) What is Machine Learning?</h3><p>Machine learning is a field within AI that focuses on creating computer programs that learn from data and improve over time. Unlike traditional programming, where a developer writes specific instructions for the computer, in machine learning, you provide the computer with data and let it figure out the patterns and rules on its own.</p><p>For example, imagine you want to teach a child to recognize dogs. You wouldn’t give them a list of features like “four legs, a tail, and barks.” Instead, you would show them lots of pictures of dogs and say, “These are dogs.” Over time, the child learns to recognize common traits of dogs. Machine learning works similarly by showing algorithms lots of examples (like pictures or data) and allowing them to learn and identify patterns on their own.</p><h3>2) Machine Learning vs AI vs Deep Learning</h3><p>You may have heard the terms AI, machine learning, and deep learning used together, but they aren’t exactly the same. Here’s how they differ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*1X3jYeNFZZUMN5lJnvA9fg.png" /><figcaption>AI vs ML vs DL</figcaption></figure><h4>Artificial Intelligence (AI)</h4><p>AI is the broadest term, referring to any technology that makes computers or machines capable of performing tasks that usually require human intelligence. This includes problem-solving, reasoning, and learning. AI can be simple, like a thermostat adjusting temperature, or more complex, like a system that plays chess.</p><h4>Machine Learning (ML)</h4><p>Machine learning is a subset of AI. It focuses on algorithms that learn from data and make decisions or predictions. Unlike traditional AI, which is rule-based, machine learning learns from examples rather than explicit instructions.</p><h4>Deep Learning</h4><p>Deep learning is a specific type of machine learning that uses artificial neural networks (ANNs), which are inspired by the human brain. Deep learning is especially good at processing complex data, such as images, speech, and text. It powers things like facial recognition and language translation.</p><h3>3) Why Machine Learning is Important</h3><p>Machine learning has become a crucial part of our data-driven world. In today’s world, data is abundant (often called “the new oil”), but without machine learning, it would be difficult to turn that data into useful information. Here’s why machine learning matters:</p><h4>Mastering Big Data</h4><p>We are surrounded by massive amounts of data, like social media posts, sensor readings, and online transactions. Machine learning can handle these large volumes of data, finding patterns and making predictions.</p><h4>Transforming Industries</h4><ul><li><strong>Healthcare:</strong> ML helps predict disease outbreaks, improve diagnostics, and personalize treatments.</li><li><strong>Finance:</strong> ML detects fraud, predicts market trends, and assesses credit risks.</li><li><strong>Retail:</strong> ML powers recommendation engines (e.g., “You might also like…”) and optimizes inventory.</li><li><strong>Other Industries:</strong> ML is used in agriculture to predict crop yields, in education to personalize learning, and in entertainment for things like curating playlists.</li></ul><h4>Powering Automation</h4><p>ML allows machines to perform repetitive tasks, freeing up time for more creative or complex work. Examples include chatbots answering customer questions, robots assembling products, and predictive models scheduling equipment maintenance.</p><h4>Growing Job Opportunities</h4><p>The demand for machine learning experts is growing rapidly. The U.S. Bureau of Labor Statistics predicts a 26% increase in ML jobs from 2023 to 2033, showing how important ML is becoming in business and society.</p><h3>4) How Does Machine Learning Work?</h3><p>The process of machine learning is like following a recipe. Here’s how it works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWgpPU5RSJocezyKq2w8Yw.png" /></figure><h4>Step 1: Data Collection</h4><p>ML needs data to learn from. This could be anything from customer records to images, sounds, or web data. The more relevant and diverse the data, the better the model will perform.</p><h4>Step 2: Data Preprocessing</h4><p>Data is often messy, incomplete, or inconsistent. Preprocessing cleans it up by:</p><ul><li>Removing duplicates.</li><li>Filling in missing values.</li><li>Standardizing data (like making sure all measurements are in the same unit).</li></ul><h4>Step 3: Choosing the Right Model</h4><p>Next, you need to choose an algorithm (model) to use. Some common models are:</p><ul><li><strong>Linear Regression:</strong> Used for predicting numbers, like house prices.</li><li><strong>Decision Trees:</strong> Used to make decisions by splitting data into branches.</li><li><strong>Neural Networks:</strong> Good for complex patterns, like image recognition.</li></ul><h4>Step 4: Training the Model</h4><p>Training is the process of feeding data into the model and adjusting it so that it can make accurate predictions. However, the model can suffer from:</p><ul><li><strong>Overfitting:</strong> When the model learns the training data too well and struggles with new data.</li><li><strong>Underfitting:</strong> When the model is too simple to learn the patterns in the data.</li></ul><h4>Step 5: Evaluating the Model</h4><p>After training, the model is tested on new data to see how well it performs. Metrics like accuracy or mean squared error (MSE) are used to measure its success.</p><h4>Step 6: Tuning and Optimization</h4><p>Models have settings (called hyperparameters) that can be adjusted to improve performance. Techniques like grid search and cross-validation help find the best settings.</p><h4>Step 7: Predictions and Deployment</h4><p>Once the model is trained and optimized, it’s deployed to make real-time predictions, such as identifying fraud in transactions or predicting stock prices.</p><h3>5) Types of Machine Learning</h3><p>Machine learning comes in four main types, each suited for different tasks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*0nMCuTX_sxAgbF_mR3e0jA.png" /></figure><h4>1. Supervised Learning</h4><p>In supervised learning, the algorithm is given labeled data (inputs paired with correct outputs). The algorithm learns from these examples to predict future outcomes. For example:</p><ul><li><strong>Classification:</strong> Sorting emails into “spam” or “not spam.”</li><li><strong>Regression:</strong> Predicting prices based on past sales.</li></ul><h4>2. Unsupervised Learning</h4><p>Unsupervised learning doesn’t use labeled data. Instead, the algorithm looks for patterns and groups the data on its own. Examples include:</p><ul><li><strong>Clustering:</strong> Grouping similar customers together.</li><li><strong>Anomaly Detection:</strong> Identifying unusual transactions or errors.</li></ul><h4>3. Reinforcement Learning</h4><p>Reinforcement learning teaches an agent to make decisions by rewarding it for good actions and penalizing it for bad ones. This type of learning is used in applications like:</p><ul><li>Game playing (e.g., AlphaGo).</li><li>Robotics (e.g., teaching a robot to pick up objects).</li></ul><h3>6) Tools for Machine Learning</h3><p>To work with machine learning, you need the right tools. Here are some of the most popular ones:</p><h4>Python for Machine Learning</h4><p>Python is widely used for machine learning due to its simplicity and powerful libraries:</p><ul><li><strong>NumPy &amp; Pandas:</strong> For data analysis.</li><li><strong>Matplotlib &amp; Seaborn:</strong> For visualizing data.</li><li><strong>Scikit-learn:</strong> For machine learning algorithms.</li><li><strong>TensorFlow &amp; PyTorch:</strong> For deep learning.</li></ul><h4>R for Machine Learning</h4><p>R is popular in statistics and academic research. It has tools for building machine learning models and is great for data analysis.</p><h4>TensorFlow &amp; PyTorch</h4><p>These libraries are used for deep learning, especially for tasks like image and speech recognition.</p><h3>7) Conclusion</h3><p>Machine learning is changing the world by turning raw data into valuable insights. It’s a versatile and powerful tool used across many industries, from healthcare to finance and entertainment. By understanding how machine learning works, its types, and the tools used, you can dive into this exciting field and explore its endless possibilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d167a700c8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>