<?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"><channel><title><![CDATA[Muniba Amin]]></title><description><![CDATA[I'm Muniba, starting my coding journey with the 100 Days of Code challenge. I'll share my progress, practice, and learnings as I take small steps each day.]]></description><link>https://muniba.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1736227827970/cc59e0e1-fd19-488e-8bcd-1b35b9072067.png</url><title>Muniba Amin</title><link>https://muniba.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 00:00:39 GMT</lastBuildDate><atom:link href="https://muniba.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Day - 5 Python Loops]]></title><description><![CDATA[Using the for loop with Python Lists
Using a for loop with Python lists allows you to iterate through
each element in the list, one at a time.
This is a fundamental way to work with lists in Python,
making it easier to process or manipulate the eleme...]]></description><link>https://muniba.dev/day-5-python-loops</link><guid isPermaLink="true">https://muniba.dev/day-5-python-loops</guid><category><![CDATA[Python]]></category><category><![CDATA[100DaysOfCode]]></category><category><![CDATA[programing]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Thu, 09 Jan 2025 11:10:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736421978384/909a0c20-60bc-4d8e-b410-cb833255f0ce.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-using-the-for-loop-with-python-lists">Using the for loop with Python Lists</h2>
<p>Using a <code>for</code> loop with <strong>Python</strong> lists allows you to <strong>iterate</strong> through</p>
<p>each element in the list, one at a time.</p>
<p>This is a fundamental way to work with lists in <strong>Python</strong>,</p>
<p>making it easier to process or <strong>manipulate</strong> the elements.</p>
<hr />
<h3 id="heading-1-iterating-over-list-items">1. <strong>Iterating Over List Items</strong></h3>
<p>You can use a <code>for</code> loop to access and perform operations on each item in the list.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-python">fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'cherry'</span>]
<span class="hljs-keyword">for</span> fruit <span class="hljs-keyword">in</span> fruits:
    print(fruit)
</code></pre>
<p><strong><em>Output:</em></strong></p>
<pre><code class="lang-python">apple
banana
cherry
</code></pre>
<hr />
<h3 id="heading-2-using-the-range-function">2. <strong>Using the</strong> <code>range()</code> Function</h3>
<p>Sometimes, you want to iterate using the index of the items. You can use the <code>range()</code> function along with the <code>len()</code> function to achieve this.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-python">fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'cherry'</span>]
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(fruits)):
    print(<span class="hljs-string">f"Index <span class="hljs-subst">{i}</span>: <span class="hljs-subst">{fruits[i]}</span>"</span>)
</code></pre>
<p><strong><em>Output:</em></strong></p>
<pre><code class="lang-python">Index <span class="hljs-number">0</span>: apple
Index <span class="hljs-number">1</span>: banana
Index <span class="hljs-number">2</span>: cherry
</code></pre>
<hr />
<h3 id="heading-3-performing-operations-on-list-items">3. <strong>Performing Operations on List Items</strong></h3>
<p>We can perform calculations, modifications, or any other operations on the elements.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-python">numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>]
squared_numbers = []
<span class="hljs-keyword">for</span> num <span class="hljs-keyword">in</span> numbers:
    squared_numbers.append(num ** <span class="hljs-number">2</span>)
print(squared_numbers)
</code></pre>
<p><strong><em>Output:</em></strong></p>
<pre><code class="lang-python">[<span class="hljs-number">1</span>, <span class="hljs-number">4</span>, <span class="hljs-number">9</span>, <span class="hljs-number">16</span>, <span class="hljs-number">25</span>]
</code></pre>
<h3 id="heading-4-nested-for-loops-with-lists">4. <strong>Nested</strong> <code>for</code> Loops with Lists</h3>
<p>When working with nested lists (lists within lists), use nested <code>for</code> loops.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-python">matrix = [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]]
<span class="hljs-keyword">for</span> row <span class="hljs-keyword">in</span> matrix:
    <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> row:
        print(item, end=<span class="hljs-string">' '</span>)
</code></pre>
<p><strong><em>Output:</em></strong></p>
<pre><code class="lang-python"><span class="hljs-number">1</span> <span class="hljs-number">2</span> <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> <span class="hljs-number">6</span> <span class="hljs-number">7</span> <span class="hljs-number">8</span> <span class="hljs-number">9</span>
</code></pre>
<hr />
<h3 id="heading-overview">Overview</h3>
<p>Use a <code>for</code> loop to <strong>iterate</strong> over each element in a list.</p>
<p>Access elements by index using <code>range()</code> .</p>
<h3 id="heading-max-function-in-python"><code>max()</code> <strong>Function in Python</strong></h3>
<p>The <code>max()</code> function in Python is used to find the maximum value in a sequence or among multiple values. It works with various data types, including numbers, strings, and more.</p>
<p><strong>Return Value</strong></p>
<p>The function returns:</p>
<ul>
<li><p>The largest item in the <strong>iterable.</strong></p>
</li>
<li><p>The largest of the provided <strong>arguments.</strong></p>
</li>
</ul>
<h3 id="heading-examples"><strong>Examples</strong></h3>
<h4 id="heading-1-maximum-in-a-list"><strong>1. Maximum in a List</strong></h4>
<pre><code class="lang-python">numbers = [<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, <span class="hljs-number">30</span>, <span class="hljs-number">40</span>, <span class="hljs-number">50</span>]
print(max(numbers))
</code></pre>
<p><strong><em>Output</em></strong></p>
<pre><code class="lang-python"><span class="hljs-number">50</span>
</code></pre>
<h4 id="heading-2-maximum-among-multiple-values"><strong>2. Maximum Among Multiple Values</strong></h4>
<pre><code class="lang-python">print(max(<span class="hljs-number">3</span>, <span class="hljs-number">7</span>, <span class="hljs-number">2</span>, <span class="hljs-number">9</span>))
</code></pre>
<p><strong><em>Output</em></strong></p>
<pre><code class="lang-python"><span class="hljs-number">9</span>
</code></pre>
<h2 id="heading-for-loops-and-the-range-function-in-python">for loops and the range ( ) function in Python</h2>
<h3 id="heading-for-loops-in-python"><strong>For Loops in Python</strong></h3>
<p>A <code>for</code> loop in Python is used to iterate over a sequence</p>
<p>(like a list, tuple, string, or range) and execute a block of code</p>
<p>for each item in the sequence.</p>
<ul>
<li><p><code>variable</code>: Takes the value of each item in the sequence, one by one.</p>
</li>
<li><p><code>sequence</code>: The data structure or iterable you want to loop over.</p>
</li>
</ul>
<h4 id="heading-example"><strong>Example:</strong></h4>
<h4 id="heading-looping-through-a-list"><strong>Looping Through a List</strong></h4>
<pre><code class="lang-python">fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'cherry'</span>]
<span class="hljs-keyword">for</span> fruit <span class="hljs-keyword">in</span> fruits:
    print(fruit)
</code></pre>
<p><strong><em>Output:</em></strong></p>
<pre><code class="lang-python">apple
banana
cherry
</code></pre>
<hr />
<h3 id="heading-the-range-function"><strong>The</strong> <code>range()</code> Function</h3>
<p>The <code>range()</code> function generates a sequence of numbers, commonly used with <code>for</code> loops. It doesn't create a list but provides a range object that is iterable.</p>
<ul>
<li><p><code>start</code>: The starting number (<strong>inclusive</strong>). The default is 0.</p>
</li>
<li><p><code>stop</code>: The ending number (<strong>exclusive</strong>). This is required.</p>
</li>
<li><p><code>step</code>: The <strong>increment</strong> (default is 1).</p>
</li>
</ul>
<h4 id="heading-examples-of-range"><strong>Examples of</strong> <code>range()</code></h4>
<ol>
<li><p><strong>Simple Range</strong></p>
<pre><code class="lang-python"> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">5</span>):  
     print(i)
</code></pre>
<p> <strong><em>Output:</em></strong></p>
<pre><code class="lang-python"> <span class="hljs-number">0</span>
 <span class="hljs-number">1</span>
 <span class="hljs-number">2</span>
 <span class="hljs-number">3</span>
 <span class="hljs-number">4</span>
</code></pre>
</li>
<li><p><strong>Range with Start and Stop</strong></p>
<pre><code class="lang-python"> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">2</span>, <span class="hljs-number">6</span>):
     print(i)
</code></pre>
<p> <strong><em>Output:</em></strong></p>
<pre><code class="lang-python"> <span class="hljs-number">2</span>
 <span class="hljs-number">3</span>
 <span class="hljs-number">4</span>
 <span class="hljs-number">5</span>
</code></pre>
</li>
<li><p><strong>Range with Step</strong></p>
<pre><code class="lang-python"> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">0</span>, <span class="hljs-number">10</span>, <span class="hljs-number">2</span>): 
     print(i)
</code></pre>
<p> <strong><em>Output:</em></strong></p>
<pre><code class="lang-python"> <span class="hljs-number">0</span>
 <span class="hljs-number">2</span>
 <span class="hljs-number">4</span>
 <span class="hljs-number">6</span>
 <span class="hljs-number">8</span>
</code></pre>
</li>
<li><p><strong>Range in Reverse</strong></p>
<pre><code class="lang-python"> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">10</span>, <span class="hljs-number">0</span>, <span class="hljs-number">-2</span>):  
     print(i)
</code></pre>
<p> <strong><em>Output:</em></strong></p>
<pre><code class="lang-python"> <span class="hljs-number">10</span>
 <span class="hljs-number">8</span>
 <span class="hljs-number">6</span>
 <span class="hljs-number">4</span>
 <span class="hljs-number">2</span>
</code></pre>
</li>
</ol>
<h3 id="heading-key-points"><strong>Key Points</strong></h3>
<ol>
<li><p><strong>For Loop</strong>: Iterates through each item in a sequence.</p>
</li>
<li><p><strong>Range Function</strong>: Generates a sequence of numbers, which can be</p>
<p> customized using <code>start</code>, <code>stop</code>, and <code>step</code> values.</p>
</li>
<li><p><strong>Combination</strong>: Use <code>range()</code> with <code>for</code> loops for precise control over iteration.</p>
<h2 id="heading-whats-the-next-milestone">What’s the next milestone?</h2>
<p> On Day <strong>6</strong> of the <strong>100 Days of Python,</strong> I will learn about <strong>Python functions and</strong> <strong>Karel.</strong></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Day 4 - Randomisation and Python Lists]]></title><description><![CDATA[Random Module
The random module in Python is used to generate
random numbers or make random selections.
It is widely used for games, testing, and other
applications where randomization is needed.
Common Functions in the random Module
1.random()
Gener...]]></description><link>https://muniba.dev/day-4-randomisation-and-python-lists</link><guid isPermaLink="true">https://muniba.dev/day-4-randomisation-and-python-lists</guid><category><![CDATA[Python]]></category><category><![CDATA[100DaysOfCode]]></category><category><![CDATA[programing]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Wed, 08 Jan 2025 14:29:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736223952168/ecb583d8-da02-4413-8ddc-f00ce70d4be1.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-random-module">Random Module</h2>
<p>The <code>random</code> module in Python is used to generate</p>
<p><strong>random numbers</strong> or make random selections.</p>
<p>It is widely used for <strong>games</strong>, <strong>testing</strong>, and other</p>
<p>applications where <strong>randomization</strong> is needed.</p>
<h3 id="heading-common-functions-in-the-random-module">Common Functions in the <code>random</code> Module</h3>
<p>1.<code>random()</code></p>
<p>Generates a random floating-point number between <code>0.0</code> (inclusive) and <code>1.0</code> (exclusive).</p>
<p>Example:</p>
<pre><code class="lang-python">   <span class="hljs-keyword">import</span> random
   print(random.random())
</code></pre>
<p><strong>Output</strong></p>
<p>0.483475829</p>
<p>2. <code>randint(a, b)</code></p>
<p>Generates a random integer between <code>a</code> and <code>b</code> (both inclusive).</p>
<p>Example:</p>
<pre><code class="lang-python">print(random.randint(<span class="hljs-number">1</span>, <span class="hljs-number">10</span>))
</code></pre>
<p><strong>Output</strong></p>
<p><em>Random number between 1 and 10</em></p>
<p>3.<code>uniform(a, b)</code></p>
<p>Generates a random floating-point number between <code>a</code> and <code>b</code>.</p>
<p>Example</p>
<pre><code class="lang-python">print(random.uniform(<span class="hljs-number">1.5</span>, <span class="hljs-number">5.5</span>))
</code></pre>
<p><strong>Output</strong></p>
<p><em>Random float between 1.5 and 5.5</em></p>
<h3 id="heading-use-cases">Use Cases</h3>
<p><strong>. Games</strong>: Randomizing player turns or shuffling cards.</p>
<p><strong>.</strong> <strong>Testing</strong>: Generating test data.</p>
<h3 id="heading-important-note">Important Note</h3>
<p>The numbers generated by the <code>random</code> module are <strong>pseudo-random,</strong> meaning they are determined by an <strong>algorithm</strong> and are not truly random.</p>
<h2 id="heading-understanding-offsets-and-appending-items-to-the-lists">Understanding Offsets and Appending Items to the Lists</h2>
<h3 id="heading-understanding-offset-index-in-lists">Understanding Offset (Index) in Lists</h3>
<p>In Python, a <strong>list</strong> is an ordered collection of items, and each item has a position called an <strong>index</strong> or <strong>offset</strong>. The index starts at <code>0</code> for the first item in the list and increments by 1 for each item.</p>
<h4 id="heading-key-points">Key Points:</h4>
<ol>
<li><p><strong>Indexing starts at 0</strong>:</p>
<ul>
<li><p>First item: Index <code>0</code></p>
</li>
<li><p>Second item: Index <code>1</code></p>
</li>
<li><p>Last item: Index <code>-1</code> (negative indexing)</p>
</li>
</ul>
</li>
<li><p><strong>Accessing items using an offset</strong>:</p>
<ul>
<li><p>You can <strong>retrieve</strong> an item by specifying its index within square brackets (<code>[]</code>).</p>
</li>
<li><p>Example:</p>
<pre><code class="lang-python">  fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'cherry'</span>]
  print(fruits[<span class="hljs-number">0</span>])  <span class="hljs-comment">#Output: apple</span>
  print(fruits[<span class="hljs-number">1</span>])  <span class="hljs-comment">#Output: banana</span>
  print(fruits[<span class="hljs-number">-1</span>]) <span class="hljs-comment">#Output: cherry (last item)</span>
</code></pre>
</li>
</ul>
</li>
</ol>
<ol start="3">
<li><strong>Out of range</strong>:</li>
</ol>
<p>    Accessing an index that doesn’t exist in the list raises an <code>IndexError</code>.</p>
<p>    Example:</p>
<pre><code class="lang-python">    (fruits[<span class="hljs-number">5</span>])  <span class="hljs-comment"># Raises IndexError</span>
</code></pre>
<h3 id="heading-appending-items-to-lists">Appending Items to Lists</h3>
<p>    In Python, appending items to a list means <strong>adding</strong> new elements to the end of an existing list. Python lists are <strong>dynamic</strong>, so you can easily modify their size by adding items.</p>
<hr />
<h3 id="heading-how-to-append-items-to-lists">How to Append Items to Lists</h3>
<ol>
<li><p><strong>Using the</strong> <code>append()</code> Method</p>
<p> The <code>append()</code> method adds a single item to the <strong>end</strong> of a list.</p>
<p> It does not create a new list; it <strong>modifies</strong> the original list in place.</p>
</li>
</ol>
<h4 id="heading-example">Example:</h4>
<pre><code class="lang-python">    numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
    numbers.append(<span class="hljs-number">4</span>)  <span class="hljs-comment"># Adds 4 to the end of the list</span>
    print(numbers)  <span class="hljs-comment"># Output: [1, 2, 3, 4]</span>
</code></pre>
<hr />
<ol start="2">
<li><p><strong>Appending a List as an Item</strong></p>
<ul>
<li>You can append an entire list as a <strong>single item.</strong> In this case, the appended list becomes a <strong>nested list</strong>.</li>
</ul>
</li>
</ol>
<h4 id="heading-example-1">Example:</h4>
<pre><code class="lang-python">    numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
    numbers.append([<span class="hljs-number">4</span>, <span class="hljs-number">5</span>])  <span class="hljs-comment"># Adds a nested list</span>
    print(numbers)  <span class="hljs-comment"># Output: [1, 2, 3, [4, 5]]</span>
</code></pre>
<hr />
<ol start="3">
<li><p><strong>Appending Items from Another Iterable</strong></p>
<p> Use the <code>extend()</code> method if you want to append multiple items from another <strong>iterable (like a list)</strong> to the current list.</p>
<p> This adds the items individually, not as a <strong>nested list.</strong></p>
</li>
</ol>
<h4 id="heading-example-2">Example:</h4>
<pre><code class="lang-python">    fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>]
    fruits.extend([<span class="hljs-string">'cherry'</span>, <span class="hljs-string">'orange'</span>])  <span class="hljs-comment"># Adds multiple items</span>
    print(fruits)  <span class="hljs-comment"># Output: ['apple', 'banana', 'cherry', 'orange']</span>
</code></pre>
<hr />
<ol>
<li><p><strong>Key Differences:</strong> <code>append()</code> vs <code>extend()</code></p>
<p> | <strong>Operation</strong> | <strong>Effect</strong> | <strong>Example</strong> | <strong>Result</strong> |
 | --- | --- | --- | --- |
 | <code>append(item)</code> | Adds <code>item</code> as a single element | <code>list.append([4, 5])</code> | <code>[1, 2, 3, [4, 5]]</code> |
 | <code>extend(iterable)</code> | Adds each element from <code>iterable</code> | <code>list.extend([4, 5])</code> | <code>[1, 2, 3, 4, 5]</code> |</p>
</li>
</ol>
<p>    <strong>When to Use</strong> <code>append()</code></p>
<ul>
<li><p>When adding one <strong>item at a time</strong>.</p>
</li>
<li><p>When you want to add a <strong>nested list.</strong></p>
</li>
</ul>
<p>    <strong>When to Use</strong> <code>extend()</code></p>
<ul>
<li><p>When adding <strong>multiple</strong> items from another <strong>iterable.</strong></p>
</li>
<li><p>When you want to <strong>merge lists.</strong></p>
</li>
</ul>
<p>    By understanding these methods, you can effectively grow and manipulate <strong>Python</strong> lists to suit your <strong>program's needs.</strong></p>
<h2 id="heading-indexerrors-and-working-with-nested-lists">IndexErrors and Working with Nested Lists</h2>
<h3 id="heading-indexerrors-in-python"><strong>IndexErrors in Python</strong></h3>
<p>    An <code>IndexError</code> occurs in <strong>Python</strong> when you try to access an element of a sequence</p>
<p>    (such as a <code>list</code>, <code>tuple</code>, or <code>string</code>) using an index that is out of range.</p>
<p>    This means the index is either <strong>greater</strong> than the last index of the sequence or</p>
<ol start="3">
<li><p><strong>less</strong> than the <strong>negative</strong> of the sequence's length.</p>
<hr />
<h3 id="heading-what-causes-indexerrors"><strong>What Causes IndexErrors?</strong></h3>
<ol>
<li><p><strong>Accessing an Index Greater Than the Sequence Length:</strong></p>
<ul>
<li>If you try to access an <strong>index</strong> that is beyond the valid range, <strong>Python</strong> raises an <code>IndexError</code>.</li>
</ul>
</li>
</ol>
</li>
</ol>
<pre><code class="lang-python">        my_list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
        print(my_list[<span class="hljs-number">3</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<ol start="2">
<li><p><strong>Using Negative Indices That Exceed the Range:</strong></p>
<ul>
<li><strong>Negative indices</strong> count from the end of a sequence. If the <strong>negative index</strong> exceeds the sequence's length, an <code>IndexError</code> occurs.</li>
</ul>
</li>
</ol>
<pre><code class="lang-python">        my_list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
        print(my_list[<span class="hljs-number">-4</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<ol start="3">
<li><p><strong>Accessing an Empty Sequence:</strong></p>
<ul>
<li>An empty sequence (like an <strong>empty list</strong>) has no <strong>valid sequence.</strong></li>
</ul>
</li>
</ol>
<pre><code class="lang-python">        empty_list = []
        print(empty_list[<span class="hljs-number">0</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<hr />
<h3 id="heading-how-to-avoid-indexerrors"><strong>How to Avoid IndexErrors</strong></h3>
<p>    <strong>Check the Length of the Sequence Before Accessing:</strong> Use the <code>len()</code> function to ensure the <strong>index</strong> is within the <strong>valid range</strong>.</p>
<ol>
<li><pre><code class="lang-python"> my_list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
 index = <span class="hljs-number">3</span>
 <span class="hljs-keyword">if</span> index &lt; len(my_list):
     print(my_list[index])
 <span class="hljs-keyword">else</span>:
     print(<span class="hljs-string">"Index out of range!"</span>)
</code></pre>
</li>
</ol>
<h3 id="heading-examples-of-indexerrors"><strong>Examples of IndexErrors</strong></h3>
<h4 id="heading-example-1-accessing-an-invalid-index"><strong>Example 1: Accessing an Invalid Index</strong></h4>
<pre><code class="lang-python">    fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"cherry"</span>]
    print(fruits[<span class="hljs-number">5</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<h4 id="heading-example-2-negative-index-exceeding-range"><strong>Example 2: Negative Index Exceeding Range</strong></h4>
<pre><code class="lang-python">    numbers = [<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, <span class="hljs-number">30</span>]
    print(numbers[<span class="hljs-number">-4</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<h4 id="heading-example-3-empty-list"><strong>Example 3: Empty List</strong></h4>
<pre><code class="lang-python">    empty_list = []
    print(empty_list[<span class="hljs-number">0</span>])  <span class="hljs-comment"># IndexError: list index out of range</span>
</code></pre>
<hr />
<h3 id="heading-key-takeaways">Key Takeaways</h3>
<ul>
<li><p>Always ensure indices are within the <strong>sequence's valid range</strong>.</p>
</li>
<li><p>Handle user inputs, <strong>dynamic indices</strong>, or <strong>uncertain data</strong> carefully to avoid <strong>unexpected errors.</strong></p>
</li>
<li><p>Use tools like <code>len()</code> and <strong>loops</strong> to work safely with sequences.</p>
</li>
<li><h2 id="heading-where-my-learning-takes-me-next">Where My Learning Takes Me Next</h2>
<p>  On Day <strong>3</strong> of the <strong>100 Days of Python,</strong> I will learn about <strong>Python Loops</strong>.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Day 3 - Control Flow and Logical Operators]]></title><description><![CDATA[Control Flow with if / else and Conditional Operators
if / else Statement :
If Statement: Checks a condition. If the condition is True,
the code inside the if block runs.
Else Statement: Runs if the if condition is False
Critical Points
The condition...]]></description><link>https://muniba.dev/day-3-control-flow-and-logical-operators</link><guid isPermaLink="true">https://muniba.dev/day-3-control-flow-and-logical-operators</guid><category><![CDATA[100DaysOfCode]]></category><category><![CDATA[Python]]></category><category><![CDATA[programing]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Mon, 06 Jan 2025 13:45:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736167947775/9bf25bb0-cc0c-442b-b189-ab1d93965cf7.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-control-flow-with-if-else-and-conditional-operators">Control Flow with if / else and Conditional Operators</h2>
<h3 id="heading-if-else-statement">if / else Statement :</h3>
<p><strong>If Statement</strong>: Checks a condition. If the condition is <code>True</code>,</p>
<p>the code inside the <code>if</code> block runs.</p>
<p><strong>Else Statement</strong>: Runs if the <code>if</code> condition is <code>False</code></p>
<h3 id="heading-critical-points">Critical Points</h3>
<p>The <code>condition</code> in the <code>if</code> the statement must be evaluated to <code>True</code> or <code>False</code>.</p>
<p>Indentation is crucial in Python; the code inside <code>if</code> or <code>else</code> must be indented.</p>
<p><strong><em>Condition Check</em></strong></p>
<p>Conditionals in Python to check a condition and tell the computer what to do in each case.</p>
<p><strong><em>Example</em></strong></p>
<p>if &lt;this condition is true&gt;:</p>
<p>    &lt;then execute this line of code&gt;</p>
<p><strong><em>What if the condition is false?</em></strong></p>
<p>The else keyword is used to define a block of code that will execute if the condition checked in the if statement is false.</p>
<pre><code class="lang-python"><span class="hljs-keyword">if</span> cow can fly:

<span class="hljs-keyword">else</span>:
    print(<span class="hljs-string">"This is real life"</span>)
</code></pre>
<p><strong>Comparator Operators</strong></p>
<p>\&gt; Greater than</p>
<p>&lt; Less than</p>
<p>\&gt;= Greater than or equal to</p>
<p>&lt;= Less than or equal to</p>
<p>\== Equal to</p>
<p>!= Not equal to</p>
<p><strong><em>Key Points</em></strong></p>
<p><strong>Conditional operators</strong> are used for comparisons.</p>
<p>They are often combined with <code>if-else</code> statements for decision-making.</p>
<p>They always return <code>True</code> or <code>False</code>.</p>
<p><strong>List of Conditional Operators</strong></p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Operator</strong></td><td><strong>Meaning</strong></td><td><strong>Example</strong></td><td><strong>Result</strong></td></tr>
</thead>
<tbody>
<tr>
<td><code>==</code></td><td>Equal to</td><td><code>5 == 5</code></td><td><code>True</code></td></tr>
<tr>
<td><code>!=</code></td><td>Not equal to</td><td><code>5 != 3</code></td><td><code>True</code></td></tr>
<tr>
<td><code>&lt;</code></td><td>Less than</td><td><code>3 &lt; 5</code></td><td><code>True</code></td></tr>
<tr>
<td><code>&gt;</code></td><td>Greater than</td><td><code>5 &gt; 3</code></td><td><code>True</code></td></tr>
<tr>
<td><code>&lt;=</code></td><td>Less than or equal to</td><td><code>3 &lt;= 3</code></td><td><code>True</code></td></tr>
<tr>
<td><code>&gt;=</code></td><td>Greater than or equal to</td><td><code>5 &gt;= 4</code></td><td><code>True</code></td></tr>
</tbody>
</table>
</div><h2 id="heading-modulo-operator-in-python"><strong>Modulo Operator (</strong><code>%</code>) in Python</h2>
<p>The <strong>modulo operator</strong> (<code>%</code>) returns the <strong>remainder</strong> when one number is divided by another.</p>
<p>It’s commonly used in programming for tasks like finding even/odd numbers.</p>
<p><strong><em>Example</em></strong></p>
<pre><code class="lang-python">result = a % b
</code></pre>
<hr />
<p><code>a</code>: Dividend (number being divided)</p>
<p><code>b</code>: Divisor (number dividing)</p>
<p><code>result</code>: Remainder after division</p>
<p>If <code>a</code> is divisible by <code>b</code>, the result is <code>0</code>.<br /><strong>Example:</strong> <code>10 % 5</code> gives <code>0</code>.</p>
<h2 id="heading-nested-if-statement-and-elif-statement">Nested if statement and elif statement</h2>
<p>A <strong>nested</strong> <code>if</code> statement is an <code>if</code> statement inside another <code>if</code> statement.</p>
<p>It allows for checking a condition only if a previous condition is <code>True</code>.</p>
<p>This structure is useful when decisions are dependent on</p>
<p><strong><em>Example</em></strong></p>
<p>You can put if/else statements inside other if/else statements. This is known as nesting. e.g.</p>
<pre><code class="lang-python"><span class="hljs-keyword">if</span> maths_score &gt;= <span class="hljs-number">90</span>:
    <span class="hljs-keyword">if</span> english_score &gt;= <span class="hljs-number">90</span>:
        print(<span class="hljs-string">"You're good at everything"</span>)
    <span class="hljs-keyword">else</span>:
        print(<span class="hljs-string">"You're good at maths"</span>)
<span class="hljs-keyword">if</span> english_score &gt;= <span class="hljs-number">90</span>:
    print(<span class="hljs-string">"You're good at english)</span>
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>You are good at everything</em></p>
<p>In this case, only when a student has over 90 in maths and English, get</p>
<p><strong><em>You are good at everything.</em></strong></p>
<h3 id="heading-key-point">Key point:</h3>
<p>You can also have<code>if</code> statements that don't have a paired <code>else</code> statement.</p>
<h3 id="heading-elif-statement-in-python">Elif Statement in Python</h3>
<p>The <code>elif</code> statement (short for "else if") allows you to check multiple conditions.</p>
<p>If one condition is <code>True</code>, the corresponding block of code runs, and the</p>
<p>remaining conditions are skipped.</p>
<p><strong><em>Example</em></strong></p>
<pre><code class="lang-python">marks = <span class="hljs-number">85</span>

<span class="hljs-keyword">if</span> marks &gt;= <span class="hljs-number">90</span>:
    print(<span class="hljs-string">"Grade: A"</span>)
<span class="hljs-keyword">elif</span> marks &gt;= <span class="hljs-number">80</span>:
    print(<span class="hljs-string">"Grade: B"</span>)
<span class="hljs-keyword">elif</span> marks &gt;= <span class="hljs-number">70</span>:
    print(<span class="hljs-string">"Grade: C"</span>)
<span class="hljs-keyword">else</span>:
    print(<span class="hljs-string">"Grade: F"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p>Grade: B</p>
<h3 id="heading-key-differences">Key Differences:</h3>
<p><strong>Nested</strong> <code>if</code>: Used when one condition depends on another condition being <code>True</code>.</p>
<p><strong>Elif</strong>: Used to check <strong>multiple independent conditions.</strong></p>
<h3 id="heading-combining-both">Combining Both:</h3>
<p>You can use both <strong>nested</strong> <code>if</code> and <code>elif</code> in the same code.</p>
<pre><code class="lang-python">age = <span class="hljs-number">25</span>
has_ticket = <span class="hljs-literal">True</span>

<span class="hljs-keyword">if</span> age &gt;= <span class="hljs-number">18</span>:
    <span class="hljs-keyword">if</span> has_ticket:
        print(<span class="hljs-string">"You can enter the event."</span>)
    <span class="hljs-keyword">else</span>:
        print(<span class="hljs-string">"You need a ticket."</span>)
<span class="hljs-keyword">elif</span> age &gt;= <span class="hljs-number">13</span>:
    print(<span class="hljs-string">"You can enter with an adult."</span>)
<span class="hljs-keyword">else</span>:
    print(<span class="hljs-string">"You are too young to enter."</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>You can enter the event.</em></p>
<h2 id="heading-multiple-if-statements">Multiple if Statements</h2>
<p>A <strong>nested</strong> <code>if</code> statement is an <code>if</code><strong>statement</strong> placed inside another <code>if</code> or <code>else</code> block.</p>
<p>It allows for checking <strong>multiple conditions</strong></p>
<pre><code class="lang-python">age = <span class="hljs-number">25</span>
has_ticket = <span class="hljs-literal">True</span>
is_vip = <span class="hljs-literal">False</span>

<span class="hljs-keyword">if</span> age &gt;= <span class="hljs-number">18</span>:
    print(<span class="hljs-string">"You are old enough to enter."</span>)

<span class="hljs-keyword">if</span> has_ticket:
    print(<span class="hljs-string">"You have a ticket."</span>)

<span class="hljs-keyword">if</span> is_vip:
    print(<span class="hljs-string">"You have VIP access."</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>You are old enough to enter.<br />You have a ticket.</em></p>
<h3 id="heading-key-points-about-multiple-if-statements"><strong>Key Points About Multiple</strong> <code>if</code> Statements:</h3>
<p><strong>Each</strong> <code>if</code>statement is evaluated independently.<br />If multiple conditions are <code>True</code>, all their corresponding blocks will execute.</p>
<p><strong>Order Matters:</strong><br />Since all <code>if</code> statements are evaluated, and the order of conditions can impact the flow of the program.</p>
<h3 id="heading-different-from-if-elif"><strong>Different from</strong> <code>if-elif</code>:</h3>
<p>In <code>if-elif</code>, only one block of code runs when a condition is <code>True</code>.</p>
<p>In multiple <code>if</code> statements, more than one block can run.</p>
<h3 id="heading-when-to-use-multiple-if-statements"><strong>When to Use Multiple</strong> <code>if</code> Statements:</h3>
<p>When you check multiple conditions Independent.</p>
<p>When multiple conditions can be true simultaneously.</p>
<h2 id="heading-logical-operators">Logical Operators</h2>
<p>Logical operators in Python are used to combine or <strong>modify</strong></p>
<p><strong>conditional</strong> statements. They return a <strong>Boolean value</strong></p>
<p>(<code>True</code> or <code>False</code>)based on the logic of the conditions provided.</p>
<h3 id="heading-types-of-logical-operators">Types of Logical Operators</h3>
<ol>
<li><code>and</code> <strong>(Logical AND)</strong></li>
</ol>
<p>Combines two conditions.</p>
<p>Returns <code>True</code> <strong>only if both conditions</strong> are <code>True</code>.</p>
<p>If either condition is <code>False</code>, it returns <code>False</code>.</p>
<ol start="2">
<li><code>or</code> <strong>(Logical OR)</strong></li>
</ol>
<p>Combines two conditions.</p>
<p>Returns <code>True</code> <strong>if at least one</strong> condition is <code>True</code>.</p>
<p>Returns <code>False</code> only if <strong>both conditions</strong> are <code>False</code>.</p>
<ol start="3">
<li><code>not</code> <strong>(Logical NOT)</strong></li>
</ol>
<p>Reverses the logical state of a condition.</p>
<p>If the condition is <code>True</code>, <code>not</code> makes it <code>False</code>, and vice versa.</p>
<h3 id="heading-when-to-use-logical-operators">When to Use Logical Operators</h3>
<p>Use <code>and</code> when <strong>all conditions</strong> need to be <code>True</code>.</p>
<p>Use <code>or</code> when <strong>at least one condition</strong> needs to be <code>True</code>.</p>
<p>Use <code>not</code> to <strong>reverse the logic</strong> of a condition.</p>
<h3 id="heading-truth-table-for-logical-operators">Truth Table for Logical Operators</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Condition 1</td><td>Condition 2</td><td><code>and</code></td><td><code>or</code></td><td><code>not Condition 1</code></td></tr>
</thead>
<tbody>
<tr>
<td><code>True</code></td><td><code>True</code></td><td><code>True</code></td><td><code>True</code></td><td><code>False</code></td></tr>
<tr>
<td><code>True</code></td><td><code>False</code></td><td><code>False</code></td><td><code>True</code></td><td><code>False</code></td></tr>
<tr>
<td><code>False</code></td><td><code>True</code></td><td><code>False</code></td><td><code>True</code></td><td><code>True</code></td></tr>
<tr>
<td><code>False</code></td><td><code>False</code></td><td><code>False</code></td><td><code>False</code></td><td><code>True</code></td></tr>
</tbody>
</table>
</div><h2 id="heading-key-highlights">Key Highlights</h2>
<p><strong>if/else Statements</strong>: Control the program's flow by executing code blocks based on conditions.</p>
<p><strong>Comparator Operators</strong>: Enable comparisons like <code>==</code>, <code>!=</code>, <code>&lt;</code>, and <code>&gt;</code>.</p>
<p><strong>Nested if and elif</strong>: Handle dependent and independent conditions effectively.</p>
<p><strong>Logical Operators</strong>: Combine conditions using <code>and</code>, <code>or</code>, and <code>not</code>.</p>
<h2 id="heading-whats-next-in-my-journey">What's next in my journey?</h2>
<p>On Day <strong>3</strong> of the <strong>100 Days of Python,</strong> I will learn about</p>
<p><strong>Randomisation and Python lists.</strong></p>
]]></content:encoded></item><item><title><![CDATA[Day 2 - Understanding Data Types
   and How to Manipulate Strings]]></title><description><![CDATA[Python Primitive Data Types
Python has four basic primitive data types.
. Integers: These are whole numbers
Example: 1 5 -10 etc
. Strings: These are used for texts enclosed in Quotes
Example:
name = "Muniba"

. Floating Point Numbers (Floats): These...]]></description><link>https://muniba.dev/day-2-understanding-data-types-and-how-to-manipulate-strings</link><guid isPermaLink="true">https://muniba.dev/day-2-understanding-data-types-and-how-to-manipulate-strings</guid><category><![CDATA[Python]]></category><category><![CDATA[100DaysOfCode]]></category><category><![CDATA[programing]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Fri, 03 Jan 2025 13:17:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735907575687/5f4fbd5e-6f09-4059-a09b-502ef09ac668.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-python-primitive-data-types">Python Primitive Data Types</h2>
<p>Python has four basic primitive data types.</p>
<p><strong>. Integers:</strong> These are whole numbers</p>
<p>Example: <code>1</code> <code>5 -10</code> etc</p>
<p><strong>. Strings:</strong> These are used for texts enclosed in Quotes</p>
<p>Example:</p>
<pre><code class="lang-python">name = <span class="hljs-string">"Muniba"</span>
</code></pre>
<p><strong>. Floating Point Numbers (Floats)</strong>: These are numbers with a decimal point.</p>
<p>Example: <code>4.13</code>, <code>3.158</code>, <code>-0.6</code> etc</p>
<p><strong>.Booleans:</strong> These are used for logical decisions.</p>
<p>Example: <code>True</code> or <code>False</code></p>
<p>These can only have <strong><em>two</em></strong> possible values.</p>
<h2 id="heading-type-error-type-checking-and-type-correction">Type Error, Type Checking, and Type Correction</h2>
<h3 id="heading-type-error">Type Error :</h3>
<p>A type error is a programming error that</p>
<p>occurs when you put the value of the <strong>wrong data type.</strong></p>
<p>Because some operations are only made for specific <strong>data types.</strong></p>
<p><code>Len( )</code> <strong>Function</strong>: It returns the <strong>number of characters</strong> in a string</p>
<h3 id="heading-example">Example</h3>
<ol>
<li><strong><em>Scenario causing a TypeError</em></strong></li>
</ol>
<pre><code class="lang-python">len(<span class="hljs-number">12345</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>TypeError</em></p>
<p><code>Len()</code> function does not like working with integers we end up with a TypeError and it breaks our code and gives us TypeError.</p>
<ol start="2">
<li><strong><em>This is the correct application of</em></strong> <code>len( )</code> <strong><em>function</em></strong></li>
</ol>
<pre><code class="lang-python">print(len(<span class="hljs-string">"hello"</span>))
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>5</em></p>
<p><strong>An Additional Case</strong></p>
<p>We have some sort of <strong><em>fancy machine</em></strong> that is going to take potatoes into fries.</p>
<p>it is probably going to have to peel the potato, wash the potato, cut it up, fry it,</p>
<p>and finally return it in the form of <strong><em>fries.</em></strong></p>
<p>Now let’s say we decided to give it a <strong><em>rock</em></strong> instead of a potato and we just pass it through the function</p>
<p>then we are going to get an <strong><em>error</em></strong></p>
<h3 id="heading-type-checking">Type Checking:</h3>
<p>Type checking is the checking of Data types whether it is</p>
<p><code>integer</code>, <code>floating</code>, <code>strings</code>, and <code>booleans</code>.</p>
<pre><code class="lang-python">print(type(<span class="hljs-string">"abc"</span>))
print(type(<span class="hljs-number">123</span>))
print(type(<span class="hljs-number">3.14</span>))
print(type(<span class="hljs-literal">True</span>))
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>&lt;class ‘str’&gt;</em></p>
<p><em>&lt;class ‘int’&gt;</em></p>
<p><em>&lt;class ‘float’&gt;</em></p>
<p><em>&lt;class ‘bool’&gt;</em></p>
<p>These are the major <strong>Primitive Data Types.</strong></p>
<h3 id="heading-type-conversion">Type Conversion</h3>
<p>Type conversion in <strong>Python</strong> is the process of converting one data type to another.</p>
<p>It is helpful when you need to perform operations between <strong>different data types.</strong></p>
<p>You can convert data into different data types using special functions.</p>
<p><strong><em>Example</em></strong></p>
<p><code>float()</code></p>
<p><code>int()</code></p>
<p><code>str()</code></p>
<h2 id="heading-mathematical-operations-in-python">Mathematical Operations in Python</h2>
<p>Python provides a wide range of mathematical operations that are used by programmers.</p>
<h3 id="heading-order-of-operations-pemdas">Order of Operations (PEMDAS)</h3>
<ul>
<li><p>Python follows the standard mathematical order of operations:</p>
<ol>
<li><p><em>Parentheses</em> <code>()</code></p>
</li>
<li><p><em>Exponents</em> <code>**</code></p>
</li>
<li><p><em>Multiplication/Division</em> <code>* /</code></p>
</li>
<li><p><em>Addition/Subtraction</em> <code>+ -</code></p>
</li>
</ol>
</li>
</ul>
<div class="hn-table">
<table>
<thead>
<tr>
<td><code>+</code></td><td>Addition</td><td><code>5 + 3</code></td><td><code>8</code></td></tr>
</thead>
<tbody>
<tr>
<td><code>-</code></td><td>Subtraction</td><td><code>10 - 4</code></td><td><code>6</code></td></tr>
<tr>
<td><code>*</code></td><td>Multiplication</td><td><code>6 * 7</code></td><td><code>42</code></td></tr>
<tr>
<td><code>/</code></td><td>Division</td><td><code>15 / 2</code></td><td><code>7.5</code></td></tr>
<tr>
<td><code>//</code></td><td>Floor Division</td><td><code>15 // 2</code></td><td><code>7</code></td></tr>
<tr>
<td><code>%</code></td><td>Modulus (Remainder)</td><td><code>15 % 4</code></td><td><code>3</code></td></tr>
<tr>
<td><code>**</code></td><td>Exponentiation (Power)</td><td><code>2 ** 3</code></td><td><code>8</code></td></tr>
</tbody>
</table>
</div><h2 id="heading-numbers-manipulations-and-f-strings-in-python">Numbers Manipulations And F Strings in Python</h2>
<h3 id="heading-number-manipulation">Number Manipulation</h3>
<p>Number manipulation is used to <strong><em>modify</em>,</strong> and <strong><em>transform</em></strong> numbers. It is done by flooring.</p>
<p><strong>Flooring a Number</strong></p>
<p>You can floor a number or remove all decimal places using <code>int( )</code></p>
<p>functions that convert a floating number with decimal places into an integer.</p>
<p><em>Example</em></p>
<p><code>int(3.7483)</code> becomes <code>3</code></p>
<h3 id="heading-rounding-a-number">Rounding a Number</h3>
<p>If you want to <strong>round</strong> a <strong>decimal number</strong> to the nearest whole number using the mathematical way</p>
<p>where anything over <code>.5</code> rounds up and anything below rounds down.</p>
<p>Then you can use the Python <code>round()</code> function.</p>
<p><strong><em>round</em></strong></p>
<p><code>(3.738492)</code></p>
<p><em>Output</em></p>
<p><code>4</code></p>
<p><strong><em>round</em></strong></p>
<p><code>(3.14159)</code></p>
<p><em>Output</em></p>
<p><code>3</code></p>
<h3 id="heading-assignment-operators">Assignment Operators</h3>
<p>Assignment operators such as the addition assignment operator +=</p>
<p>will add the number on the right to the original value of the variable</p>
<p>on the left and assign the new value to the variable.</p>
<p><code>+=</code></p>
<p><code>-=</code></p>
<p><code>*=</code></p>
<p>`/=`</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Operator</strong></td><td><strong>Description</strong></td><td><strong>Example</strong></td><td><strong>Explanation</strong></td><td><strong>Result</strong></td></tr>
</thead>
<tbody>
<tr>
<td><code>+=</code></td><td>Add and assign</td><td><code>x += 5</code></td><td><code>x = x + 5</code></td><td><code>x</code> becomes <code>15</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>-=</code></td><td>Subtract and assign</td><td><code>x -= 3</code></td><td><code>x = x - 3</code></td><td><code>x</code> becomes <code>7</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>*=</code></td><td>Multiply and assign</td><td><code>x *= 2</code></td><td><code>x = x * 2</code></td><td><code>x</code> becomes <code>20</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>/=</code></td><td>Divide and assign</td><td><code>x /= 2</code></td><td><code>x = x / 2</code></td><td><code>x</code> becomes <code>5.0</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>//=</code></td><td>Floor divide and assign</td><td><code>x //= 3</code></td><td><code>x = x // 3</code></td><td><code>x</code> becomes <code>3</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>%=</code></td><td>Modulus and assign</td><td><code>x %= 4</code></td><td><code>x = x % 4</code></td><td><code>x</code> becomes <code>2</code> if <code>x = 10</code></td></tr>
<tr>
<td><code>**=</code></td><td>Exponentiation and assign</td><td><code>x **= 3</code></td><td><code>x = x ** 3</code></td><td><code>x</code> becomes <code>1000</code> if <code>x = 10</code></td></tr>
</tbody>
</table>
</div><h3 id="heading-f-strings">f-Strings</h3>
<p>In Python, we can use <strong>f-strings</strong> to insert a variable or an expression into a string.</p>
<pre><code class="lang-python">age = <span class="hljs-number">12</span>

print(<span class="hljs-string">f"I am <span class="hljs-subst">{age}</span> years old"</span>)
</code></pre>
<p><strong>Output</strong></p>
<p><em>I am 12 years old</em></p>
<h2 id="heading-final-project">Final project</h2>
<p>The final project of today is to make a <strong>Tip Calculator.</strong></p>
<h2 id="heading-tip-calculator">Tip Calculator</h2>
<p>We are going to build a Tip Calculator.</p>
<pre><code class="lang-python">print(<span class="hljs-string">"Welcome to the tip calculator!"</span>)
bill = float(input(<span class="hljs-string">"What was the total bill? $"</span>))
tip = int(input(<span class="hljs-string">"What percentage tip would you like to give? 10 12 15 "</span>))
people = int(input(<span class="hljs-string">"How many people to split the bill? "</span>))
tip_as_percent = tip / <span class="hljs-number">100</span>
total_tip_amount = bill * tip_as_percent
bill_per_percent = totall_bill / people
final_amount = round(bill_per_person, <span class="hljs-number">2</span>)
print(<span class="hljs-string">f"Each person should pay: $<span class="hljs-subst">{finalamount}</span>"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>Welcome to the tip calculator!</em></p>
<p><em>What was the total bill?</em> <code>$153.45</code></p>
<p><em>What percentage tip would you like to give? 10 12 15</em> <code>15</code></p>
<p><em>How many people to split the bill?</em> <code>5</code></p>
<p><em>Each person should pay:</em> <code>$35.29</code></p>
<h2 id="heading-what-will-i-learn-next">What will I Learn Next?</h2>
<p>On Day <strong>3</strong> of the <strong>100 Days of Python,</strong> I will learn about <strong>Control Flow and Logical Operators</strong>.</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Day 1 - Working With Variables In Python To Manage Data]]></title><description><![CDATA[Today I learned
Printing to the Console in Python
print() function is used to display the Information to the user
For Example. Texts, Numbers, and output or the result of any calculations.
It is also used to debug code and make a program interactive ...]]></description><link>https://muniba.dev/day-1-beginner-working-with-variables-in-python-to-manage-data</link><guid isPermaLink="true">https://muniba.dev/day-1-beginner-working-with-variables-in-python-to-manage-data</guid><category><![CDATA[Python]]></category><category><![CDATA[100DaysOfCode]]></category><category><![CDATA[journey]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Wed, 01 Jan 2025 12:20:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735807046838/e1c74d9f-14ca-4f61-a8d8-f9ed398fafce.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-today-i-learned">Today I learned</h2>
<h3 id="heading-printing-to-the-console-in-python">Printing to the Console in Python</h3>
<p><code>print()</code> function is used to display the Information to the user</p>
<p>For Example. <strong><em>Texts</em></strong>, <strong><em>Numbers</em>,</strong> and output or the result of any <strong><em>calculations.</em></strong></p>
<p>It is also used to <strong><em>debug</em></strong> code and make a program interactive by showing messages.</p>
<p><strong>Example</strong></p>
<pre><code class="lang-python">print(<span class="hljs-string">"Today I learned!"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>Today I Learned!</em></p>
<p>Text is always inside the <strong>strings</strong><code>(““)</code>otherwise the <strong><em>syntax error</em></strong> is shown on the screen.</p>
<p>The reason for putting up strings inside the <strong><em>parentheses</em></strong> is to tell the computer that it is not the code it is just text.</p>
<h3 id="heading-string-manipulation">String Manipulation</h3>
<p>String manipulation in Python refers to performing various operations on strings, such as altering their <strong><em>contents</em></strong>, extracting parts of them, or checking certain properties.</p>
<p><strong><em>Python</em></strong> makes string manipulation easy with a variety of functions.</p>
<p><strong>Example</strong></p>
<ol>
<li><em>\n character separates one line into two separate lines.</em></li>
</ol>
<pre><code class="lang-python">Print(<span class="hljs-string">"Hello Muniba!\nHello Muniba!"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>Hello Muniba!</em></p>
<p><em>Hello Muniba!</em></p>
<ol start="2">
<li><em>Spacing</em></li>
</ol>
<pre><code class="lang-python"><span class="hljs-keyword">print</span> (<span class="hljs-string">"Hello"</span> + <span class="hljs-string">" "</span> +<span class="hljs-string">"Muniba!"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>Hello Muniba!</em></p>
<h3 id="heading-code-intelligence">Code Intelligence</h3>
<p>Code intelligence in Python refers to the advanced tools, techniques, and features available to help developers write, understand, and maintain Python code more efficiently.</p>
<p>It involves features like auto-completion, error detection, intelligent suggestions, and navigation, which can help developers code faster and with fewer mistakes.</p>
<ol>
<li><strong>Code Navigation</strong></li>
</ol>
<p>Code navigation allows you to easily <strong><em>navigate</em></strong> to specific parts of your code. It includes features such as <em>go to</em> <strong><em>definition, find references</em></strong> and <strong><em>peek definition</em></strong>. This is useful for large codebases or when working with external libraries.</p>
<p><strong>Example</strong>: If you click on a function name in your <strong><em>Python</em></strong> code, the <strong>IDE</strong> can take you to its definition, even if it’s in a different file or module.</p>
<ol start="2">
<li><strong>Auto-Completion and Code Suggestions</strong></li>
</ol>
<p>Auto-completion or code suggestions help developers by predicting and completing the code they are typing. <strong><em>Python-specific</em></strong> features such as methods or classes from libraries are suggested as you type, saving time and preventing errors.</p>
<ol start="3">
<li><strong>Error Detection</strong></li>
</ol>
<p>Code intelligence tools in Python can identify <strong>syntax errors</strong> while you are coding.</p>
<p>They alert you to issues in the code such as missing <strong><em>parentheses</em>, <em>incorrect function calls</em>, or <em>undefined variables</em></strong>, before running the code.</p>
<p><strong>Example</strong>: If you forget to close a bracket in a function call or assign a variable that isn't defined, code intelligence will highlight the error in real time.</p>
<h3 id="heading-the-python-input-function">The Python Input Function</h3>
<p>In Python, the <code>input()</code>function is used to take input from the user something like a name or any other piece of information.</p>
<p>It allows you to interact with the program by <strong><em>prompting</em></strong> the user to enter some data, and then the program processes that data and shows the next result of that data.</p>
<p><strong><em>How it works:</em></strong></p>
<ol>
<li><p>The <code>input()</code>function displays the prompt to the user (if provided).</p>
</li>
<li><p>The program waits for the user to enter some data through the keyboard.</p>
</li>
<li><p>Once the user enters the data and press <strong>Enter</strong>, the <code>input()</code> function returns the input as a string.</p>
</li>
</ol>
<p><strong><em>Example</em></strong></p>
<pre><code class="lang-python">name = input(<span class="hljs-string">"Enter your name: "</span>)

print(<span class="hljs-string">"Hello "</span> + name + <span class="hljs-string">"!"</span>)
</code></pre>
<p><strong><em>Output</em></strong></p>
<p><em>Enter your name: Muniba</em></p>
<p><em>Hello Muniba!</em></p>
<h3 id="heading-python-variables">Python Variables</h3>
<p>In Python, <strong>variables</strong> are used to store data values that can be used later in the program.</p>
<p>They act as "containers" for holding data, such as numbers, strings, or more complex data types like <strong><em>lists</em>, <em>dictionaries,</em> and <em>objects.</em></strong></p>
<p><strong><em>Variable Namings Rules :</em></strong></p>
<p>A variable name must start with a letter <strong>(a-z, A-Z)</strong> or an <strong>underscore ( _ )</strong>, followed by letters,</p>
<p><strong><em>numbers (0-9</em>),</strong> or an underscore. It cannot be a keyword (<strong><em>reserved word in Python)</em></strong></p>
<p>like <code>if</code>, <code>for</code>, <code>class</code>, etc</p>
<h2 id="heading-final-project">Final project</h2>
<p>At the end of the day, we will make a <strong><em>Band name generator</em></strong> Like I want to create or</p>
<p>someone else wants to create their Band name so let’s take a look at the <strong><em>final project</em></strong> of today</p>
<h2 id="heading-band-name-generator">Band Name Generator</h2>
<pre><code class="lang-python">print(<span class="hljs-string">"Welcome to Band Name Generator"</span>)

city = input(<span class="hljs-string">"Which city did you grow up in?"</span>)

pet= input(<span class="hljs-string">"What is the name of your pet?"</span>)

print(<span class="hljs-string">"Your Band name could be: "</span>+ city + <span class="hljs-string">" "</span> +pet)
</code></pre>
<h3 id="heading-output">Output</h3>
<p><em>Welcome to Band Name Generator</em></p>
<p><em>Which city did you grow up in? Haripur</em></p>
<p><em>What is the name of your pet? Cat</em></p>
<p><em>Your band name could be: Haripur Cat</em></p>
<h2 id="heading-the-problems-i-faced-today">The Problems I Faced Today</h2>
<p><strong><em>Variable naming</em></strong> in Python follows certain rules,</p>
<p>such as avoiding reserved keywords,</p>
<p>starting with letters or underscores, and using only <strong><em>letters, numbers, and underscores.</em></strong></p>
<p>By practicing these rules repeatedly, you can improve your ability to name <strong><em>variables</em></strong> correctly and consistently.</p>
<h2 id="heading-most-important-things-i-learned">Most Important Things I learned</h2>
<p><strong><em>Indentation</em></strong> is very important in Python.</p>
<p>If the code is not correctly indented it will show you an <strong><em>Indentation Error.</em></strong></p>
<h2 id="heading-i-will-work-on-it-more">I will Work on it More</h2>
<p>I will practice more on the <strong><em>variable naming</em></strong> and the <code>input()</code>function.</p>
<p>Because it was a bit difficult for me.</p>
<h2 id="heading-what-will-i-learn-next">What will I Learn Next?</h2>
<p>I will learn data types and how to manipulate strings in Day <strong>2</strong> of <strong>100</strong> Days.</p>
]]></content:encoded></item><item><title><![CDATA[Starting My 100 Days of Code Journey with Python]]></title><description><![CDATA[I’m super excited to start the "100 Days of Code" course by Dr. Angela Yu on Udemy! This course is all about learning Python step by step while building real projects. It’s perfect for beginners like me who want to improve their coding skills and lea...]]></description><link>https://muniba.dev/starting-my-100-days-of-code-journey-with-python</link><guid isPermaLink="true">https://muniba.dev/starting-my-100-days-of-code-journey-with-python</guid><category><![CDATA[Python]]></category><category><![CDATA[100DaysOfCode]]></category><dc:creator><![CDATA[Muniba Amin]]></dc:creator><pubDate>Tue, 31 Dec 2024 14:07:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735653676589/93a760c7-7725-4cda-b340-01a17dcaf533.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I’m super excited to start the "<a target="_blank" href="https://www.udemy.com/course/100-days-of-code/">100 Days of Code</a>" course by Dr. Angela Yu on Udemy! This course is all about learning Python step by step while building real projects. It’s perfect for beginners like me who want to improve their coding skills and learn by doing.</p>
<h2 id="heading-what-the-course-includes"><strong>What the Course Includes</strong></h2>
<p>This course is packed with so much to learn! Some of the things I’ll be working on are:</p>
<ul>
<li><p>Python programming basics and advanced concepts.</p>
</li>
<li><p>Creating websites with Flask.</p>
</li>
<li><p>Working with data using Pandas and NumPy.</p>
</li>
<li><p>Learning about Machine Learning with Scikit-Learn.</p>
</li>
<li><p>Front-end basics like HTML, CSS, and Bootstrap.</p>
</li>
<li><p>Using Git and GitHub for version control.</p>
</li>
<li><p>Deploying projects with Heroku and GitHub Pages.</p>
</li>
</ul>
<p>Each day focuses on a project, so by the end of the course, I’ll have built 100 small Python projects! That’s so exciting because I’ll not only learn the theory but also create something cool every day.</p>
<h2 id="heading-why-i-picked-this-course"><strong>Why I Picked This Course</strong></h2>
<p>I’ll be starting my B.S. in Artificial Intelligence soon, and Python is super important for AI. I wanted a course that’s beginner-friendly but also helps me build a strong foundation for the future. This one stood out because it’s fun, practical, and covers a lot of useful topics.</p>
<h2 id="heading-what-youll-find-on-this-blog"><strong>What You’ll Find on This Blog</strong></h2>
<p>I’ll be writing about my experience with this course, sharing what I learned, what I struggled with, and how I overcame challenges. I’ll post updates regularly, so if you’re just starting out or thinking about learning Python, I hope my blog will help and inspire you.</p>
<p>I can’t wait to see where this journey takes me. Stay tuned for updates!</p>
]]></content:encoded></item></channel></rss>