<?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 Sumayyea Salahuddin on Medium]]></title>
        <description><![CDATA[Stories by Sumayyea Salahuddin on Medium]]></description>
        <link>https://medium.com/@sumayya.malik?source=rss-cb77dd3bbaaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pnJqxlyvUe7Mpdj6.jpg</url>
            <title>Stories by Sumayyea Salahuddin on Medium</title>
            <link>https://medium.com/@sumayya.malik?source=rss-cb77dd3bbaaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 21:10:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumayya.malik/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[Mastering Object-Oriented Programming: The Four Pillars Explained with C++]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-object-oriented-programming-the-four-pillars-explained-with-c-967a99acb46b?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/967a99acb46b</guid>
            <category><![CDATA[encapsulation]]></category>
            <category><![CDATA[object-oriented-program]]></category>
            <category><![CDATA[inheritance]]></category>
            <category><![CDATA[polymorphism]]></category>
            <category><![CDATA[abstraction]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 19:02:32 GMT</pubDate>
            <atom:updated>2024-12-29T19:02:32.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYE0foGYFhBcTon0m4e9Xw.jpeg" /><figcaption><strong>Photo by DALL-E</strong></figcaption></figure><p>Object-oriented programming (OOP) is a programming paradigm based on the concept of objects, which can encapsulate data and behavior. The foundational concepts of OOP are:</p><ol><li><strong>Encapsulation</strong></li><li><strong>Inheritance</strong></li><li><strong>Polymorphism</strong></li><li><strong>Abstraction</strong></li></ol><h3>Encapsulation</h3><p>— <strong>Definition:</strong> Encapsulation is the bundling of data (attributes) and methods (functions) that operate on the data within a single unit, called a class. An object is an instance of a class. Access to the data is restricted to prevent unintended interference and misuse.</p><p>— <strong>Key Benefit: </strong>Protects the internal state of an object and ensures that changes to the data occur through controlled methods (getters and setters).</p><p><strong>— Example: </strong>In the following code, <strong>encapsulation </strong>is demonstrated by keeping the data members (name and age) private in the <em>Person </em>class and restricting direct access. Controlled access is provided through public getter and setter methods, ensuring data integrity and hiding implementation details from the user. Figure 1 shows the output of the encapsulation example.</p><pre>#include &lt;iostream&gt;<br>#include &lt;cstring&gt;<br>using namespace std;<br><br>class Person {<br>private:<br>    string name; // Private data member<br>    int age;<br><br>public:<br>    // Constructor<br>    Person(string n, int a) : name(n), age(a) {}<br><br>    // Getter for name<br>    string getName() const { return name; }<br><br>    // Setter for name<br>    void setName(string n) { name = n; }<br><br>    // Getter for age<br>    int getAge() const { return age; }<br><br>    // Setter for age<br>    void setAge(int a) { age = a; }<br><br>    void display() const {<br>        cout &lt;&lt; &quot;Name: &quot; &lt;&lt; name &lt;&lt; &quot;, Age: &quot; &lt;&lt; age &lt;&lt; &quot; years&quot; &lt;&lt; endl;<br>    }<br>};<br><br>int main() {<br>    Person p1(&quot;Ahmad Ali&quot;, 21);<br>    p1.display();<br>    p1.setAge(22);<br>    cout &lt;&lt; &quot;Updated Age: &quot; &lt;&lt; p1.getAge() &lt;&lt; &quot; years&quot; &lt;&lt; endl;<br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*uxzlbCW7vnXy9_wjdhGhLw.png" /><figcaption><strong>Figure 1: Encapsulation Example Output</strong></figcaption></figure><h3>Inheritance</h3><p>— <strong>Definition:</strong> Inheritance allows a new class (child or derived class) to acquire the properties and methods of an existing class (parent or base class). The child class can also have additional features or override existing ones.</p><p>— <strong>Key Benefit: </strong>Promotes code reuse and establishes a hierarchical relationship between classes.</p><p><strong>— Example: </strong>In the following code, <strong>inheritance </strong>is demonstrated as the <em>Rectangle </em>and <em>Triangle </em>classes derive from the <em>Polygon </em>class, inheriting its height and length attributes. This allows both derived classes to reuse the setValue method and calculate their respective areas based on the inherited data. Figure 2 shows the output of the inheritance example.</p><pre>#include &lt;iostream&gt;<br>using namespace std;<br><br>class Polygon {<br>protected:<br>    int height; // Protected data member<br>    int length;<br><br>public:<br>    // Set value for height and length<br>    void setValue(int h, int l) { height = h; length = l; }<br>};<br><br>class Rectangle: public Polygon {<br>public:<br>    // Rectangle area<br>    int area() { return (height*length); }<br>};<br><br>class Triangle: public Polygon {<br>public:<br>    // Triangle area<br>    double area() { return (height*length)/2; }<br>};<br><br>int main() {<br>    Rectangle r1;<br>    Triangle t1;<br><br>    r1.setValue(10, 20);<br>    cout &lt;&lt; &quot;Area of rectangle: &quot; &lt;&lt; r1.area() &lt;&lt; endl;<br><br>    t1.setValue(10, 20);<br>    cout &lt;&lt; &quot;Area of triangle: &quot; &lt;&lt; t1.area() &lt;&lt; endl;<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*TgTMEeaZZRb3O5bsERDjDw.png" /><figcaption><strong>Figure 2: Inheritance Example Output</strong></figcaption></figure><h3>Polymorphism</h3><p>— <strong>Definition:</strong> Polymorphism allows objects to be treated as instances of their parent class, enabling the same operation to behave differently based on the object. It can be achieved through function overloading, operator overloading, or method overriding (using virtual functions in C++).</p><p>— <strong>Key Benefit: </strong>Enhances flexibility and scalability of code by allowing different classes to define their versions of a method.</p><p><strong>— Example: </strong>In the following code, <strong>polymorphism </strong>is demonstrated through the use of a virtual draw method in the base <em>Shape </em>class. The derived classes (<em>Circle</em>, <em>Rectangle</em>, and <em>Triangle</em>) override this method, allowing the same pointer (<strong><em>sh</em></strong>) to call different draw implementations depending on the object it points to, enabling dynamic behavior at runtime. Figure 3 shows the output of the polymorphism example.</p><pre>#include &lt;iostream&gt;<br>using namespace std;<br><br>class Shape {<br>public:<br>    // Virtual function in base/parent class<br>    virtual void draw() { cout &lt;&lt; &quot;Draw a shape&quot; &lt;&lt; endl; }<br>};<br><br>class Circle: public Shape {<br>public:<br>    // Draw circle<br>    void draw() { cout &lt;&lt; &quot;Draw a circle&quot; &lt;&lt; endl; }<br>};<br><br>class Rectangle: public Shape {<br>public:<br>    // Draw rectangle<br>    void draw() { cout &lt;&lt; &quot;Draw a rectangle&quot; &lt;&lt; endl; }<br>};<br><br>class Triangle: public Shape {<br>public:<br>    // Draw triangle<br>    void draw() { cout &lt;&lt; &quot;Draw a triangle&quot; &lt;&lt; endl; }<br>};<br><br>int main() {<br>    Shape *sh;<br>    <br>    Shape s1;<br>    Circle c1;<br>    Rectangle r1;<br>    Triangle t1;<br><br>    sh = &amp;s1;<br>    sh -&gt; draw();<br><br>    sh = &amp;c1;<br>    sh -&gt; draw();<br><br>    sh = &amp;r1;<br>    sh -&gt; draw();<br><br>    sh = &amp;t1;<br>    sh -&gt; draw();<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*z7RUagdrebESeP6lg-KtGg.png" /><figcaption><strong>Figure 3: Polymorphism Example Output</strong></figcaption></figure><h3>Abstraction</h3><p>— <strong>Definition:</strong> Abstraction focuses on exposing only the essential features of an object while hiding the implementation details. In C++, abstraction is typically achieved using abstract classes (classes with at least one pure virtual function).</p><p>— <strong>Key Benefit: </strong>Simplifies the design and makes the code easier to maintain.</p><p><strong>— Example: </strong>In the following code, <strong>abstraction</strong> is demonstrated by the <em>Shape </em>class, which acts as an abstract base class with a pure virtual draw function. This hides implementation details and enforces that all derived classes (<em>Circle</em>, <em>Rectangle</em>, <em>Triangle</em>) provide their own specific implementation of the draw method, focusing only on the essential functionality. Figure 4 shows the output of the abstraction example.</p><pre>#include &lt;iostream&gt;<br>using namespace std;<br><br>class Shape { // Abstract Class<br>public:<br>    // Pure virtual function in base/parent class<br>    virtual void draw() = 0;<br>};<br><br>class Circle: public Shape { // Concrete Class 1<br>public:<br>    // Draw circle<br>    void draw() { cout &lt;&lt; &quot;Draw a circle&quot; &lt;&lt; endl; }<br>};<br><br>class Rectangle: public Shape { // Concrete Class 2<br>public:<br>    // Draw rectangle<br>    void draw() { cout &lt;&lt; &quot;Draw a rectangle&quot; &lt;&lt; endl; }<br>};<br><br>class Triangle: public Shape { // Concrete Class 3<br>public:<br>    // Draw triangle<br>    void draw() { cout &lt;&lt; &quot;Draw a triangle&quot; &lt;&lt; endl; }<br>};<br><br>int main() {<br>    Shape *sh;<br>    <br>    Circle c1;<br>    Rectangle r1;<br>    Triangle t1;<br><br>    sh = &amp;c1;<br>    sh -&gt; draw();<br><br>    sh = &amp;r1;<br>    sh -&gt; draw();<br><br>    sh = &amp;t1;<br>    sh -&gt; draw();<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*x7nerUEi9B0M_hER2A9Zmw.png" /><figcaption><strong>Figure 4: Abstraction Example Output</strong></figcaption></figure><p>Please visit the following GitHub Repository containing this article code:</p><p><a href="https://github.com/SSalahuddin/OOP-Cplusplus">GitHub - SSalahuddin/OOP-Cplusplus</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me reach a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=967a99acb46b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding SFML: A Comprehensive Guide to the Simple and Fast Multimedia Library — Part 2”]]></title>
            <link>https://medium.com/@sumayya.malik/understanding-sfml-a-comprehensive-guide-to-the-simple-and-fast-multimedia-library-part-2-995ac50b8911?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/995ac50b8911</guid>
            <category><![CDATA[code-block]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[sfml]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[2d-game-development]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Mon, 22 Jan 2024 04:43:04 GMT</pubDate>
            <atom:updated>2024-01-22T10:33:10.203Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding SFML: A Comprehensive Guide to the Simple and Fast Multimedia Library — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7GajJr8OxYMSqTJCduQUA.png" /><figcaption><strong>SFML in C++ using Code::Blocks IDE (Image by Author)</strong></figcaption></figure><p>To interface <strong>SFML v2.5.1</strong> with <strong>Code::Blocks v20.03 using GCC MinGW 64-bit</strong>, you’ll need to follow these updated steps. It’s essential to ensure that your versions of Code::Blocks, SFML, and the MinGW compiler are compatible.</p><h3><strong>Steps for Code::Blocks v20.03 and SFML v2.5.1</strong></h3><ol><li><strong>Install Code::Blocks MinGW 64-bit</strong><br> — Ensure you have Code::Blocks v20.03 installed with the MinGW 64-bit compiler. If not, download and install from the [Code::Blocks website](<a href="http://www.codeblocks.org/downloads/26">http://www.codeblocks.org/downloads/26</a>) as shown in Figure 1.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjDbUjIFfHboFVIbZECb7Q.jpeg" /><figcaption><strong>Figure 1: Download Code::Blocks</strong></figcaption></figure><p><strong>2. Download SFML v2.5.1</strong><br> — Download SFML v2.5.1 from the [SFML download page](<a href="https://www.sfml-dev.org/download/sfml/2.5.1/">https://www.sfml-dev.org/download/sfml/2.5.1/</a>). Make sure to choose the version compiled with GCC 7.3.0 MinGW (SEH) — 64-bit as shown in Figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBVOOkTmNIJTURL58KX6Tw.jpeg" /><figcaption><strong>Figure 2: Download SFML</strong></figcaption></figure><p><strong>3. Extract SFML SDK</strong><br> — Extract the downloaded SFML archive to a known directory, for example, `C:\SFML-2.5.1` as shown in Figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*8CU4vweA7R3F8XG__avG1Q.jpeg" /><figcaption><strong>Figure 3: Extract the downloaded SFML archive to C:\SFML-2.5.1</strong></figcaption></figure><p><strong>4. Create a New Project in Code::Blocks</strong><br> — Open Code::Blocks and create a new project.<br> — Choose “Console Application” as shown in Figure 4a and select C++ as the language as shown in Figure 4b.<br> — Give a suitable project title as shown in Figure 4c.<br> — Select GNU GCC Compiler as shown in Figure 4d and Finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MGoFfi9C95J_jIzNChoT0g.jpeg" /><figcaption><strong>Figure 4a: Create a New Project as a Console Application</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3__yd0NsLI8dTEWGMVnqA.jpeg" /><figcaption><strong>Figure 4b: Select C++ as the language</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hePcaSnXWs6XKWqnFC2-SA.jpeg" /><figcaption><strong>Figure 4c: Give Project Suitable Project Title</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L45dZuZuFpb4ObSK3_E5UQ.jpeg" /><figcaption><strong>Figure 4d: Select GNU GCC Compiler and Finish</strong></figcaption></figure><p><strong>5. Configure Project to Use SFML</strong><br> — Go to ‘Project’ -&gt; ‘Build options’ as shown in Figure 5a.<br> — Under the ‘Search directories’ tab, select ‘Compiler option’, and add the path to the SFML include folder, such as `C:\SFML-2.5.1\include` as shown in Figure 5b.<br> — Under the ‘Search directories’ tab, select ‘Linker option’, and add the path to the SFML include folder, such as `C:\SFML-2.5.1\lib` as shown in Figure 5c.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSWmLwwoYSotYX-Fc1HBuA.jpeg" /><figcaption><strong>Figure 5a: Project’ -&gt; ‘Build options</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRjlirbJVD-vmmkoqLY9eQ.jpeg" /><figcaption><strong>Figure 5b: Search directories -&gt; Compiler option -&gt; `C:\SFML-2.5.1\include`</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Zgx8nT6ojjYGseSIjltqg.jpeg" /><figcaption><strong>Figure 5c: Search directories -&gt; Linker option -&gt; `C:\SFML-2.5.1\lib`</strong></figcaption></figure><p><strong>6. Link SFML Libraries</strong><br> — In ‘Build options’, select ‘Debug’, then navigate to the ‘Linker settings’ tab. Add SFML libraries by linking to the .a files located in `C:\SFML-2.5.1\lib`. For example, link `libsfml-audio-d.a`, `libsfml-graphics-d.a`, `libsfml-main-d.a`, `libsfml-network-d.a`,`libsfml-system-d.a`, and`libsfml-window-d.a`. This is shown in Figure 6a.<br> — In ‘Build options’, select ‘Release’, then navigate to the ‘Linker settings’ tab. Add SFML libraries by linking to the .a files located in `C:\SFML-2.5.1\lib`. For example, link `libsfml-audio.a`, `libsfml-graphics.a`, `libsfml-main.a`, `libsfml-network.a`,`libsfml-system.a`, and`libsfml-window.a`. This is shown in Figure 6b.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eV2TNyo8MHL10eVozAwE3w.jpeg" /><figcaption><strong>Figure 6a: Linking for Debug</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWeV41vCgQ_FNFjRmPCH6A.jpeg" /><figcaption><strong>Figure 6b: Linking for Release</strong></figcaption></figure><p><strong>7. Copy SFML DLLs</strong><br> — Copy the SFML DLLs from `C:\SFML-2.5.1\bin` to your project’s binary directory (where your executable is generated). <br> — To do so, Build and run the project for Debug as shown in Figure 7a. This will generate bin and obj folders containing Debug folder in each directory. <br> — Next, Build and run the project for Release as shown in Figure 7b. This will generate bin and obj folders containing Release folder in each directory. <br> — Finally, copy all the SFML DLLs from `C:\SFML-2.5.1\bin`to `gamefolder\firstGame\bin\Debug`and `gamefolder\firstGame\bin\Release`.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0NZUQ1GbXnItsF4U__TzA.jpeg" /><figcaption><strong>Figure 7a: Build and run for Debug</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXi0scotCI5O-RC9xTe5gA.jpeg" /><figcaption><strong>Figure 7b: Build and run for Release</strong></figcaption></figure><p><strong>8. Configure Compiler</strong><br> — Make sure that Code::Blocks is configured to use the GCC MinGW 64-bit compiler.<br> — You can check this in ‘Settings’ -&gt; ‘Compiler’ and ensure it’s set to GNU GCC Compiler as shown in Figure 8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rEPHsPWUOlTdsbn751oPQ.jpeg" /><figcaption><strong>Figure 8: Confirm Right Compiler is Selected</strong></figcaption></figure><p><strong>9. Write Test Code</strong><br> — Include the necessary SFML headers (e.g., `#include &lt;SFML/Graphics.hpp&gt;`) in your source files.<br> — Use the following test code as shown in Figure 9a. Build and run it. If everything works you should see a green circle as an output as shown in Figure 9b.<br> — Now, you are ready to implement your SFML application.</p><pre>#include &lt;SFML/Graphics.hpp&gt;<br><br>int main(){<br>    sf::RenderWindow window(sf::VideoMode(200, 200), &quot;SFML works!&quot;);<br>    sf::CircleShape shape(100.f);<br>    shape.setFillColor(sf::Color::Green);<br><br>    while (window.isOpen()){<br>        sf::Event event;<br>        while (window.pollEvent(event)){<br>            if (event.type == sf::Event::Closed)<br>                window.close();<br>        }<br><br>        window.clear();<br>        window.draw(shape);<br>        window.display();<br>    }<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7ri0K0mfM55gwJu4JbWmQ.jpeg" /><figcaption><strong>Figure 9a: SFML Test Code</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xOSibbkhWgVaCrsFkF7zDQ.jpeg" /><figcaption><strong>Figure 9b: Output of SFML Test Code</strong></figcaption></figure><p><strong>10. Build and Run</strong><br> — Now, build your project in Code::Blocks. If everything is set up correctly, you should be able to compile and run your SFML application.</p><p><strong>Troubleshooting Tips</strong></p><p>1. <strong>Linker Errors:</strong> Ensure you’re linking against the correct library files for your build configuration (debug/release).</p><p><strong>2. DLL Errors:</strong> If you encounter runtime errors about missing DLLs, double-check you’ve copied all the required SFML DLLs.</p><p><strong>3. Compilation Errors:</strong> Make sure the SFML headers are correctly included and the compiler settings are correctly configured.</p><p><strong>References</strong></p><ol><li>SFML Download Page: [SFML 2.5.1](<a href="https://www.sfml-dev.org/download/sfml/2.5.1/">https://www.sfml-dev.org/download/sfml/2.5.1/</a>)</li><li>Code::Blocks Official Download: [Code::Blocks](<a href="http://www.codeblocks.org/downloads/26">http://www.codeblocks.org/downloads/26</a>)</li><li>SFML and Code::Blocks Tutorial: [SFML and Code::Blocks](<a href="https://www.sfml-dev.org/tutorials/2.5/start-cb.php">https://www.sfml-dev.org/tutorials/2.5/start-cb.php</a>)</li></ol><p>This guide is tailored for specific versions of Code::Blocks, SFML, and the MinGW compiler. Adaptations might be required for different setups or newer versions.</p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=995ac50b8911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Understanding SFML: A Comprehensive Guide to the Simple and Fast Multimedia Library — Part 1”]]></title>
            <link>https://medium.com/@sumayya.malik/understanding-sfml-a-comprehensive-guide-to-the-simple-and-fast-multimedia-library-part-1-a3276a87566c?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3276a87566c</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[sfml]]></category>
            <category><![CDATA[2d-game-development]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Mon, 22 Jan 2024 02:18:33 GMT</pubDate>
            <atom:updated>2024-01-22T10:14:24.654Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding SFML: A Comprehensive Guide to the Simple and Fast Multimedia Library — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hRDOsmGKSGgCVZnIfVpTw.png" /><figcaption><strong>2D Game in SFML C++ (Image by Author)</strong></figcaption></figure><p>SFML, short for Simple and Fast Multimedia Library, is a freely available and open-source software development library. Its purpose is to offer a straightforward and efficient interface to several elements of a personal computer, including graphics, audio, network, and input devices. It is implemented using the C++ programming language and provides developers with an object-oriented application programming interface (API). This enables developers to take advantage of the capabilities of C++ while working at a higher level of abstraction. SFML is frequently used for the development of games and interactive applications owing to its straightforwardness and efficiency.</p><p><strong>Key Features:</strong></p><ol><li><strong>Graphics Module: </strong>SFML offers a straightforward interface for window creation, OpenGL context management, and user input handling (keyboard, mouse, joystick, etc.). It provides functionality for rendering 2D visuals and performing fundamental transformations.</li><li><strong>Audio Module:</strong> Provides features for playing sounds and music, capturing audio, and manipulating audio data in real-time. It is constructed using OpenAL as its foundation and includes spatialization capabilities for producing three-dimensional sound effects.</li><li><strong>Network Module: </strong>Enables the establishment of connections between applications, namely utilizing the TCP and UDP protocols. This feature is helpful for the creation of multiplayer games or applications with network capabilities.</li><li><strong>Window Module:</strong> Oversees the process of creating windows, managing events, and handling input. It simplifies the intricacies of several operating systems, offering a cohesive interface.</li><li><strong>System Module:</strong> Offers fundamental features such as multithreading, timing measurement, and user data streams. It serves as the foundation for additional modules.</li></ol><p><strong>Advantages:</strong></p><p><strong>Cross-platform:</strong> Compatible with multiple platforms such as Windows, macOS, Linux, and other operating systems.</p><p><strong>Object-Oriented Design:</strong> It is well-suited for C++ projects.</p><p><strong>Lightweight and Fast:</strong> Optimized for high efficiency, which is essential in time-sensitive applications such as gaming.</p><p><strong>Community and Documentation:</strong> Boasts a community that provides ample support and an API that is thoroughly documented, thereby ensuring accessibility for novices.</p><p><strong>Use Cases:</strong></p><p><strong>Game Development:</strong> Popular for indie game developers due to its simplicity and flexibility.</p><p><strong>Educational Purposes: </strong>Often used in academic settings to teach game development and multimedia processing.</p><p><strong>Multimedia Applications:</strong> For developing applications that require graphics, audio, or network functionality.</p><p><strong>Comparison with Other Libraries:</strong></p><p>SFML is frequently contrasted with SDL (Simple DirectMedia Layer) and Allegro. Although SDL and Allegro are capable of performing multimedia tasks, SFML is particularly recognized for its object-oriented approach, which aligns more closely with contemporary C++ standards. SDL, however, is a C library and may be used in applications where a C interface is more appropriate.</p><p><strong>Getting Started:</strong></p><p>To get started with the use of SFML, developers can acquire the library from its official website and proceed with the comprehensive tutorials and documentation provided. SFML is additionally bolstered by a multitude of community-provided bindings for other programming languages, including .NET, Python, and Ruby.</p><p><strong>References:</strong></p><ol><li>SFML Official Website: [SFML](<a href="https://www.sfml-dev.org/">https://www.sfml-dev.org/</a>)</li><li>SFML GitHub Repository: [SFML GitHub](<a href="https://github.com/SFML/SFML">https://github.com/SFML/SFML</a>)</li><li>“SFML Game Development By Example” — A book for beginners in SFML game development.</li><li>Online communities and forums, such as Stack Overflow, for community support and discussions.</li></ol><p>The combination of SFML’s user-friendly interface and its robust capabilities renders it a favored option among developers seeking to construct interactive and visually immersive applications.</p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3276a87566c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 10 — Multiple-Choice Quiz Game in Python]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-10-multiple-choice-quiz-game-in-python-a2745a6812f7?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2745a6812f7</guid>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-training-course]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 18:55:19 GMT</pubDate>
            <atom:updated>2023-11-01T19:08:22.729Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 10 — 🧠Multiple-Choice Quiz Game in Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32nPzHB8iMN2hiBGUZAkYg.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@nguyendhn?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Nguyen Dang Hoang Nhu</strong></a><strong> on </strong><a href="https://unsplash.com/photos/person-writing-on-white-paper-qDgTQOYk6B8?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article provides a detailed overview of <strong>Day 10 in a Python coding challenge</strong>. The Python script provided is an improved quiz game that allows users to test their knowledge by selecting from multiple-choice options. It achieves this by presenting a series of questions and providing feedback based on the user’s responses. Let us analyze the code:</p><pre># Day 10<br># Multiple-Choice Quiz Game in Python</pre><p>The comments at the beginning of the code indicate that it is part of a coding challenge (Day 10) and its objective is to implement an interactive, multiple-choice quiz game in Python where the user is asked a series of questions, given feedback on their responses, and congratulated as the quiz champion if they answer all questions correctly.</p><pre>import random</pre><p>The first line of code imports Python’s random module that generates random numbers and simplifies program randomization. It can generate random integers, floating-point numbers, sequence items, shuffling lists, creating random seeds for repeatability, and more, making it a versatile tool for Python programs that need randomness.</p><pre># Define a list of questions, options, and correct answers as a dictionary<br>quiz_data = [<br>    {<br>        &quot;question&quot;: &quot;Which planet is known as the Red Planet?&quot;,<br>        &quot;options&quot;: [&quot;a) Venus&quot;, &quot;b) Mercury&quot;, &quot;c) Earth&quot;, &quot;d) Mars&quot;],<br>        &quot;correct_answer&quot;: &quot;d&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;Who developed the theory of relativity?&quot;,<br>        &quot;options&quot;: [&quot;a) Isaac Newton&quot;, &quot;b) Albert Einstein&quot;, &quot;c) Galileo Galilei&quot;, &quot;d) Marie Curie&quot;],<br>        &quot;correct_answer&quot;: &quot;b&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;What is the largest ocean on Earth?&quot;,<br>        &quot;options&quot;: [&quot;a) Pacific Ocean&quot;, &quot;b) Indian Ocean&quot;, &quot;c) Southern Ocean&quot;, &quot;d) Atlantic Ocean&quot;],<br>        &quot;correct_answer&quot;: &quot;a&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;What is the fastest land animal on Earth?&quot;,<br>        &quot;options&quot;: [&quot;a) Cheetah&quot;, &quot;b) Lion&quot;, &quot;c) Elephant&quot;, &quot;d) Giraffe&quot;],<br>        &quot;correct_answer&quot;: &quot;a&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;Who is the author of the Harry Potter book series?&quot;,<br>        &quot;options&quot;: [&quot;a) J.R.R. Tolkien&quot;, &quot;b) C.S. Lewis&quot;, &quot;c) J.K. Rowling&quot;, &quot;d) George R.R. Martin&quot;],<br>        &quot;correct_answer&quot;: &quot;c&quot;<br>    }<br>]</pre><p>The dictionary <strong>quiz_data</strong> consists of lists, each containing three key-value pairs: a question, a list of possible options, and its corresponding answer.</p><pre># Create a list of indices from 0 to the length of quiz_data - 1<br>indices = list(range(len(quiz_data)))</pre><p>Next, a list of indices ranging from 0 to the length of <strong>quiz_data</strong> minus 1 is generated and stored in variable <strong>indices</strong>.</p><pre># Shuffle the indices to get a random order<br>random.shuffle(indices)</pre><p>These indices are then shuffled to randomize the order of the questions.</p><pre># Initialize a variable to keep track of the score<br>score = 0</pre><p>The variable <strong>score</strong> is initialized to keep track of the user’s score.</p><pre># Iterate through the questions and ask the user<br>for i in indices:<br>    current_question = quiz_data[i]<br>    <br>    print(f&quot;Question: {current_question[&#39;question&#39;]}&quot;)<br>    for option in current_question[&#39;options&#39;]:<br>        print(option)<br>    <br>    user_answer = input(&quot;Your answer (a/b/c/d): &quot;).strip().lower()<br>    <br>    # Check if the user&#39;s answer is correct<br>    if user_answer == current_question[&#39;correct_answer&#39;]:<br>        print(&quot;Correct!\n&quot;)<br>        score += 1<br>    else:<br>        print(f&quot;Wrong! The correct answer is: {current_question[&#39;correct_answer&#39;].upper()}\n&quot;)</pre><p>Next, the code iterates through the questions in the <strong>quiz_data</strong> dictionary and interacts with the user. Here is a breakdown of the various elements:</p><ol><li>The statement “<em>for i in indices:</em>” iterates through the list of indices, determining the randomized order of the questions. The script is designed to present each question to the user individually.</li><li>The line “<em>current_question = quiz_data[i]</em>” retrieves the current question from the <strong>quiz_data</strong> dictionary by using the current index, <strong>i</strong>.</li><li>The line “<em>print(f”Question: {current_question[‘question’]}”)</em>” displays the current question to the user.</li><li>The <em>“for option in the current_question[‘options’]:”</em> is the loop function that is used to display every possible option for the current question.</li><li>The user’s answer is obtained through the input function and prompting them to enter a choice (a/b/c/d). The <em>strip()</em> method is used to extract the answer entered by the user. The <em>lower()</em> method then converts the answer to lowercase and any leading or trailing whitespaces are removed.</li><li>The statement <em>“if user_answer == current_question[‘correct_answer’]:”</em> is used to verify if the user’s answer matches the correct answer for the current question. If the user’s answer is correct, the script will inform them and increase the score variable. However, if the answer is incorrect, the script will display the correct answer to the user.</li></ol><pre># Display the final score<br>print(f&quot;You scored {score} out of {len(quiz_data)} questions.&quot;)</pre><p>Once all the questions have been answered, the code will display the user’s final score by printing the number of correct answers out of the total number of questions.</p><pre>if score == len(quiz_data):<br>    print(&quot;Congratulations! You are the quiz champion!&quot;)</pre><p>If the user answers all the questions correctly and their score is equal to the number of questions, the code will display a message saying “Congratulations!” You are the champion of the quiz!</p><p>To summarize, this code creates an engaging multiple-choice quiz experience for the user. It is designed to provide feedback based on the user’s responses and will congratulate them if they answer all the questions correctly.</p><p>Here is the complete code:</p><pre># Day 10<br># Multiple-Choice Quiz Game in Python<br><br>import random<br><br># Define a list of questions, options, and correct answers as a dictionary<br>quiz_data = [<br>    {<br>        &quot;question&quot;: &quot;Which planet is known as the Red Planet?&quot;,<br>        &quot;options&quot;: [&quot;a) Venus&quot;, &quot;b) Mercury&quot;, &quot;c) Earth&quot;, &quot;d) Mars&quot;],<br>        &quot;correct_answer&quot;: &quot;d&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;Who developed the theory of relativity?&quot;,<br>        &quot;options&quot;: [&quot;a) Isaac Newton&quot;, &quot;b) Albert Einstein&quot;, &quot;c) Galileo Galilei&quot;, &quot;d) Marie Curie&quot;],<br>        &quot;correct_answer&quot;: &quot;b&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;What is the largest ocean on Earth?&quot;,<br>        &quot;options&quot;: [&quot;a) Pacific Ocean&quot;, &quot;b) Indian Ocean&quot;, &quot;c) Southern Ocean&quot;, &quot;d) Atlantic Ocean&quot;],<br>        &quot;correct_answer&quot;: &quot;a&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;What is the fastest land animal on Earth?&quot;,<br>        &quot;options&quot;: [&quot;a) Cheetah&quot;, &quot;b) Lion&quot;, &quot;c) Elephant&quot;, &quot;d) Giraffe&quot;],<br>        &quot;correct_answer&quot;: &quot;a&quot;<br>    },<br>    {<br>        &quot;question&quot;: &quot;Who is the author of the Harry Potter book series?&quot;,<br>        &quot;options&quot;: [&quot;a) J.R.R. Tolkien&quot;, &quot;b) C.S. Lewis&quot;, &quot;c) J.K. Rowling&quot;, &quot;d) George R.R. Martin&quot;],<br>        &quot;correct_answer&quot;: &quot;c&quot;<br>    }<br>]<br><br># Create a list of indices from 0 to the length of quiz_data - 1<br>indices = list(range(len(quiz_data)))<br><br># Shuffle the indices to get a random order<br>random.shuffle(indices)<br><br># Initialize a variable to keep track of the score<br>score = 0<br><br># Iterate through the questions and ask the user<br>for i in indices:<br>    current_question = quiz_data[i]<br>    <br>    print(f&quot;Question: {current_question[&#39;question&#39;]}&quot;)<br>    for option in current_question[&#39;options&#39;]:<br>        print(option)<br>    <br>    user_answer = input(&quot;Your answer (a/b/c/d): &quot;).strip().lower()<br>    <br>    # Check if the user&#39;s answer is correct<br>    if user_answer == current_question[&#39;correct_answer&#39;]:<br>        print(&quot;Correct!\n&quot;)<br>        score += 1<br>    else:<br>        print(f&quot;Wrong! The correct answer is: {current_question[&#39;correct_answer&#39;].upper()}\n&quot;)<br><br># Display the final score<br>print(f&quot;You scored {score} out of {len(quiz_data)} questions.&quot;)<br><br>if score == len(quiz_data):<br>    print(&quot;Congratulations! You are the quiz champion!&quot;)</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*3O5qDCK7Ik9p3V5YJdr8wg.jpeg" /><figcaption><strong>Output — Day 10 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2745a6812f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 09 — Calculating Arithmetic Mean in Python]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-09-calculating-arithmetic-mean-in-python-45c0a25c7605?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c0a25c7605</guid>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 11:23:09 GMT</pubDate>
            <atom:updated>2023-10-31T11:23:09.678Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 09 — Calculating Arithmetic Mean in Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDevC7FrDzl6VzoAgCcbSw.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@sm83?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Peter Scherbatykh</strong></a><strong> on </strong><a href="https://unsplash.com/photos/person-in-blue-long-sleeve-shirt-using-black-laptop-computer-EA4RFyQfptk?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article provides an in-depth look at <strong>Day 09 of a Python coding challenge</strong>. The following code calculates the <strong>arithmetic mean</strong>, also known as the <em>average</em>, of a set of numbers that are provided by the user. The <strong>arithmetic mean</strong> is a widely used measure of central tendency in statistics. To calculate it, you add together a set of numbers and then divide the sum by the count of those numbers. The representative value provides a comprehensive understanding of the entire data set.</p><p>Let’s explore a comprehensive, step-by-step breakdown:</p><pre># Day 09<br># Calculating Arithmetic Mean in Python</pre><p>The comments at the beginning of the code indicate that it is part of a coding challenge (Day 09). This program is meant for the calculation of the arithmetic mean in the Python programming language.</p><pre># Initialize the exit flag to control the loop<br>exit_flag = False</pre><p>The <strong>exit_flag</strong> variable is initially set to <strong>False</strong>. This variable will control the execution of the while loop.</p><pre># Initialize an empty list to store numbers<br>num_list = list()</pre><p>A list <strong>num_list </strong>is created to store the numbers provided by the user. Initially, the list is empty.</p><pre># Continuously prompt the user to enter numbers<br>while not exit_flag:<br>    data = input(&quot;Enter a number (type &#39;done&#39; to finish): &quot;)<br><br>    if data.lower() == &quot;done&quot;:      # Allowing both &#39;done&#39; and &#39;Done&#39;<br>        exit_flag = True<br>    else:<br>        try:<br>            value = float(data)     # Convert input to a float type<br>            num_list.append(value)  # Add the value to the list<br>        except ValueError:<br>            print(&quot;Invalid input. Please enter a valid number.&quot;)</pre><p>The statement <em>while not exit_flag</em> establishes a loop that will continue until the <strong>exit_flag</strong> becomes <strong>True</strong>. This implies that the loop will keep running until the exit condition is satisfied.</p><p>The line <em>data = input(“Enter a number (type ‘done’ to finish): “)</em> prompts the user to enter a number or type “done” to indicate that they have finished entering input.</p><p>The statement <em>if data.lower() == “done”</em> checks whether the input, after being converted to lowercase, is equal to the string “done”. This condition indicates that the user wants to stop providing numbers.</p><p>If the input is not “done”, the code will try to convert the input into a float type by using the<em> value = float(data)</em> statement. After a successful conversion, the value is added to the <strong>num_list</strong> by using the <em>num_list.append(value)</em> method.</p><p>The <em>except ValueError</em> block is used to catch any value that cannot be converted to a float. When such a value is encountered, it triggers an error message that prompts the user to enter a valid number.</p><pre># Calculate the average of the numbers in the list<br>if num_list:    # Check if the list is not empty to avoid ZeroDivisionError<br>    average = sum(num_list) / len(num_list)<br>    print(&quot;Average: &quot;, average)    # Print the calculated average<br>else:<br>    print(&quot;No data entered. Cannot calculate average.&quot;)  # Print a message if no data is entered</pre><p>The statement <em>if num_list</em> verifies if the list <strong>num_list</strong> is not empty, indicating that there is at least one number in the list. It is necessary to include this check in order to avoid a <strong>ZeroDivisionError</strong> that could potentially occur if the list is empty.</p><p>If the list is not empty, the code calculates the average of the numbers in <strong>num_list</strong>. It does this by summing all the values in <strong>num_list</strong> using the <em>sum()</em> function, and then dividing the sum by the total number of elements in the list using the<em> len() </em>function.</p><p>The calculated average is stored in a variable called <strong>average</strong>. The line <em>print(“Average: “, average)</em> is used to display the calculated average to the user.</p><p>If the user does not enter any data, the code will display the message “No data entered.” Unable to calculate the average. This message indicates that no calculation could be performed due to the absence of input data from the user.</p><p>In summary, this code allows the user to input a sequence of numbers. The code prompts the user for numerical inputs repeatedly until they enter the term ‘done’. The numerical inputs are stored in a list for future processing. Once the user has finished providing numbers, the code proceeds to calculate the average of the values in the list and then displays the resulting value. If the user does not enter any data, the script will notify them that a calculation cannot be performed. The script takes into consideration potential errors, such as invalid inputs, in order to ensure the program runs smoothly.</p><p>Here is the complete code:</p><pre># Day 09<br># Calculating Arithmetic Mean in Python<br><br># Initialize the exit flag to control the loop<br>exit_flag = False<br><br># Initialize an empty list to store numbers<br>num_list = list()<br><br># Continuously prompt the user to enter numbers<br>while not exit_flag:<br>    data = input(&quot;Enter a number (type &#39;done&#39; to finish): &quot;)<br><br>    if data.lower() == &quot;done&quot;:      # Allowing both &#39;done&#39; and &#39;Done&#39;<br>        exit_flag = True<br>    else:<br>        try:<br>            value = float(data)     # Convert input to a float type<br>            num_list.append(value)  # Add the value to the list<br>        except ValueError:<br>            print(&quot;Invalid input. Please enter a valid number.&quot;)<br><br># Calculate the average of the numbers in the list<br>if num_list:    # Check if the list is not empty to avoid ZeroDivisionError<br>    average = sum(num_list) / len(num_list)<br>    print(&quot;Average: &quot;, average)    # Print the calculated average<br>else:<br>    print(&quot;No data entered. Cannot calculate average.&quot;)  # Print a message if no data is entered</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*3ZzUE3ptjZTIpNCBH1V4WA.jpeg" /><figcaption><strong>Output — Day 09 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c0a25c7605" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 08 —The Art of Predicting Numbers]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-08-the-art-of-predicting-numbers-fc279a2fe4cb?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc279a2fe4cb</guid>
            <category><![CDATA[pytho]]></category>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 10:18:10 GMT</pubDate>
            <atom:updated>2023-10-31T10:20:53.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLjS2je-9g7wXswvgiQqIQ.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@altumcode?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>AltumCode</strong></a><strong> on </strong><a href="https://unsplash.com/photos/macbook-pro-on-top-of-desk-RrFvYtCwO8E?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article provides an in-depth look at <strong>Day 08 of a Python coding challenge</strong>. The following code creates a basic number-guessing game using Python. Let’s delve into a detailed step-by-step explanation:</p><pre># Day 08<br># Guess the Number in Python</pre><p>The comments at the beginning of the code indicate that it is part of a coding challenge (Day 08). This Python program is about a guessing game where the user needs to guess a randomly generated number within a certain range.</p><pre>import random</pre><p>The code imports the <strong>random </strong>module in order to generate random numbers. This module offers various functions that allow you to generate random numbers, select random elements from a list, and shuffle sequences. This module is commonly utilized in applications such as simulations, gaming, and cryptography, where randomness plays a crucial role.</p><pre># Generate a random number between 1 and 5<br>num = random.randint(1, 5)<br>guess = None</pre><p>A random number between 1 and 5 is stored in the variable <strong>num</strong>, while the variable <strong>guess</strong> is initialized to <strong>None</strong> to initiate the game.</p><pre># Keep prompting the user to guess the number until they guess correctly<br>while guess != num:<br>    # Allowing the user to input their guess as an integer<br>    guess = int(input(&quot;Guess a number between 1 and 5: &quot;))<br>    <br>    # Check if the guessed number matches the generated random number<br>    if guess == num:<br>        print(&quot;Congratulations! You won :)&quot;)  # Print a success message if the guess is correct<br>        break                                 # Exit the loop if the guess is correct<br>    else:<br>        print(&quot;Try Again :(&quot;)  # Print a message to try again if the guess is incorrect</pre><p>The user is asked to guess a number between 1 and 5 using the <em>input</em> function. The input provided by the user is then converted to an integer.</p><p>The program verifies whether the user’s guess matches the randomly generated number, <strong>num</strong>. If the guess is correct, it will display the message “Congratulations!” “You won!” the program exclaims as it breaks out of the loop.</p><p>If the user’s guess is incorrect, the program will print “Try Again :(“ and continue to prompt the user for another guess until they guess correctly.</p><p>The game will continue until the user guesses the correct number. Once they guess it correctly, they will receive a congratulatory message.</p><p>To summarize, this code creates a game that will continue until the user guesses the correct number. Once they guess it correctly, they will receive a congratulatory message.</p><p>Here is the complete code:</p><pre># Day 08<br># Guess the Number in Python<br><br>import random<br><br># Generate a random number between 1 and 5<br>num = random.randint(1, 5)<br>guess = None<br><br># Keep prompting the user to guess the number until they guess correctly<br>while guess != num:<br>    # Allowing the user to input their guess as an integer<br>    guess = int(input(&quot;Guess a number between 1 and 5: &quot;))<br>    <br>    # Check if the guessed number matches the generated random number<br>    if guess == num:<br>        print(&quot;Congratulations! You won :)&quot;)  # Print a success message if the guess is correct<br>        break                                 # Exit the loop if the guess is correct<br>    else:<br>        print(&quot;Try Again :(&quot;)  # Print a message to try again if the guess is incorrect</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*FnMZcN6V1tiC5NYswPzGgw.jpeg" /><figcaption><strong>Output — Day 08 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc279a2fe4cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 07 — Employee Hour-Rate Conversion in Python]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-07-employee-hour-rate-conversion-in-python-75e6f2c62083?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/75e6f2c62083</guid>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 18:06:31 GMT</pubDate>
            <atom:updated>2023-10-31T10:36:27.676Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 07 — Employee Hour-Rate Conversion in Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31m2V7ML2WhFHGB_s7h1YQ.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@anniespratt?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Annie Spratt</strong></a><strong> on </strong><a href="https://unsplash.com/photos/sittin-people-beside-table-inside-room-hCb3lIB8L8E?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article offers a comprehensive insight into the <strong>Day 07 of a Python coding challenge</strong>. The following code calculates an employee’s pay based on the number of hours worked and an hourly rate. Here’s a step-by-step explanation:</p><pre># Day 07<br># Employee Hour-Rate Conversion in Python</pre><p>The comments at the beginning of the code indicate that it is part of a coding challenge (Day 07). The primary goal of this code is to develop a Python program responsible for the calculation of employee pay based on the input of hours worked and hourly rates.</p><pre># Get user inputs for hours worked and hourly rate<br>hours_worked = float(input(&quot;Enter hours worked: &quot;))<br>hourly_rate = float(input(&quot;Enter hourly rate (in $): &quot;))</pre><p>The program starts by requesting user input for the number of hours worked and the hourly rate. These inputs are stored in the variables <strong>hours_worked</strong> and <strong>hourly_rate</strong>.</p><pre># Calculate pay based on regular and overtime rates<br>if hours_worked &gt; 40:<br>    regular_pay = 40 * hourly_rate<br>    overtime_hours = hours_worked - 40<br>    overtime_pay = overtime_hours * (hourly_rate * 1.5)  # Overtime rate is 1.5 times the hourly rate<br>    total_pay = regular_pay + overtime_pay<br>else:<br>    total_pay = hours_worked * hourly_rate</pre><p>Next, the code calculates the pay based on regular and overtime rates. If the <strong>hours_worked</strong> are greater than 40, it means the employee has worked overtime.</p><p>For regular hours (up to 40 hours), the code calculates the <strong>regular_pay</strong> by multiplying the first 40 hours by the <strong>hourly_rate</strong>.</p><p>If there are additional hours beyond 40, the code calculates the <strong>overtime_hours</strong> by subtracting 40 from the total hours worked. The <strong>overtime_pay</strong> is then calculated as the product of <strong>overtime_hours</strong> and 1.5 times the <strong>hourly_rate</strong>. Overtime pay is typically higher, at 1.5 times the hourly rate, as per standard labor regulations.</p><p>The <strong>total_pay</strong> is calculated by summing up the regular pay and the overtime pay, if applicable.</p><pre># Display the calculated pay<br>print(f&quot;Pay: ${total_pay:.2f}&quot;)</pre><p>Finally, the program displays the calculated pay, formatted as a dollar amount with two decimal places, using an f-string.</p><p>In summary, the code efficiently handles the calculation of employee pay, distinguishing between regular and overtime hours, and provides the total pay based on the input values.</p><p>Here is the complete code:</p><pre># Day 07<br># Employee Hour-Rate Conversion in Python<br><br># Get user inputs for hours worked and hourly rate<br>hours_worked = float(input(&quot;Enter hours worked: &quot;))<br>hourly_rate = float(input(&quot;Enter hourly rate (in $): &quot;))<br><br># Calculate pay based on regular and overtime rates<br>if hours_worked &gt; 40:<br>    regular_pay = 40 * hourly_rate<br>    overtime_hours = hours_worked - 40<br>    overtime_pay = overtime_hours * (hourly_rate * 1.5)  # Overtime rate is 1.5 times the hourly rate<br>    total_pay = regular_pay + overtime_pay<br>else:<br>    total_pay = hours_worked * hourly_rate<br><br># Display the calculated pay<br>print(f&quot;Pay: ${total_pay:.2f}&quot;)</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*FiVylJLi5CgmgbPsXlcthA.jpeg" /><figcaption><strong>Output — Day 07 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75e6f2c62083" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 06 — Improved Password Generator in Python [ Part 2]]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-06-improved-password-generator-in-python-part-2-702bc24fea54?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/702bc24fea54</guid>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[python-projects]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Sat, 28 Oct 2023 18:32:45 GMT</pubDate>
            <atom:updated>2023-10-31T08:04:57.773Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 06 — Improved Password Generator 🔐in Python [ Part 2]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7iNiEXDPrFA43Bl0q6aIQ.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@altumcode?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>AltumCode</strong></a><strong> on </strong><a href="https://unsplash.com/photos/silver-macbook-turned-on-XMFZqrGyV-Q?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This is <strong>part 2 of the password generator in Python</strong>. This article provides a detailed explanation of the improved version of the password generator. Let us analyze the code:</p><pre># Day 06<br># 🔐Improved Password Generator in Python 💡</pre><p>The comments at the beginning of the code indicate that there was an improvement made to the password generator in Python.</p><pre>import random<br>import string</pre><p>The random and string libraries are imported to make it easier to generate random characters for the password.</p><p>The Python <em>random</em> library offers functions that generate random numbers. These functions are valuable for various tasks such as simulating chance events, randomization, and creating unpredictable outcomes in applications.</p><p>The <em>string </em>library provides a variety of useful functions for working with strings. It is particularly helpful for tasks involving string manipulation, text processing, and generating random strings. For example, it can be used to generate passwords or tokens. These libraries enhance the functionality and versatility of Python programs.</p><pre># Define a function to generate a random password of a specified length.<br>def generate_password(length):<br>    # Define the character set for the password, including letters, digits, and punctuation.<br>    chars = string.ascii_letters + string.digits + string.punctuation<br><br>    # Generate the password by joining random characters from the character set.<br>    password = &#39;&#39;.join(random.choice(chars) for _ in range(length))<br><br>    # Return the generated password.<br>    return password</pre><p>Next, the function <strong>generate_password</strong> has been defined. It accepts the desired length of the password as input and generates a random password. This is achieved by defining a character set that encompasses both lowercase and uppercase letters, digits, and special punctuation characters. The password is generated by randomly selecting characters from a set and combining them. The password that has been generated is then returned.</p><pre># Prompt the user to enter the desired password length as an integer.<br>length = int(input(&quot;Enter password length: &quot;))</pre><p>The user is asked to input the desired length of the password. The length is stored as an integer.</p><pre># Initialize an empty string to store the generated password.<br>password = &quot;&quot;</pre><p>A <strong>password </strong>is initialized as an empty string to store the generated password.</p><pre># Check if the password length is less than 8 characters.<br>if length &lt; 8:<br>    # If the length is insufficient, inform the user.<br>    print(&quot;Password length should be at least 8 characters.&quot;)<br>else:<br>    # If the length is adequate, generate a password using the &#39;generate_password&#39; function.<br>    password = generate_password(length)<br>    <br>    # Display the generated password to the user.<br>    print(&quot;Generated Password:&quot;, password)</pre><p>The code verifies whether the specified password length is less than 8 characters. If the password length is less than 8 characters, a message will be displayed to inform the user.</p><p>If the specified length is 8 characters or more, the code will generate a password by calling the <em>generate_password</em> function with the specified length. The password generated is stored in the variable called <strong>password</strong>.</p><p>Finally, the code will display the generated password to the user.</p><p>To summarize, this code creates a password generator that produces a secure and random password of the desired length. It ensures that the password is at least 8 characters long for security reasons.</p><p>Here is the complete code:</p><pre># Day 06<br># 🔐Improved Password Generator in Python 💡<br><br>import random<br>import string<br><br># Define a function to generate a random password of a specified length.<br>def generate_password(length):<br>    # Define the character set for the password, including letters, digits, and punctuation.<br>    chars = string.ascii_letters + string.digits + string.punctuation<br><br>    # Generate the password by joining random characters from the character set.<br>    password = &#39;&#39;.join(random.choice(chars) for _ in range(length))<br><br>    # Return the generated password.<br>    return password<br><br># Prompt the user to enter the desired password length as an integer.<br>length = int(input(&quot;Enter password length: &quot;))<br><br># Initialize an empty string to store the generated password.<br>password = &quot;&quot;<br><br># Check if the password length is less than 8 characters.<br>if length &lt; 8:<br>    # If the length is insufficient, inform the user.<br>    print(&quot;Password length should be at least 8 characters.&quot;)<br>else:<br>    # If the length is adequate, generate a password using the &#39;generate_password&#39; function.<br>    password = generate_password(length)<br>    <br>    # Display the generated password to the user.<br>    print(&quot;Generated Password:&quot;, password)</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*Yto3c3_s0bMHhElvN2mxeQ.jpeg" /><figcaption><strong>Output — Day 06 Improved Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=702bc24fea54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 06 — Password Generator in Python ]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-06-password-generator-in-python-9aadefdacc0e?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aadefdacc0e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 18:46:16 GMT</pubDate>
            <atom:updated>2023-10-31T07:58:42.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 06 — Password Generator 🔐in Python [ Part 1]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2vQr4HkdiWUBYjHPQhnsPA.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@agk42?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Alex Knight</strong></a><strong> on </strong><a href="https://unsplash.com/photos/laptop-computer-beside-coffee-mug-j4uuKnN43_M?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article provides a detailed description of <strong>Day 06 of a Python coding challenge</strong>. The following code creates a password generator in Python. The user can specify the desired length of the password. Let us analyze the code:</p><pre># Day 06<br># 🔐 Crafting a Simple Password Generator in Python 💡</pre><p>The comments at the beginning of the code indicate that it is part of a coding challenge (Day 06) and its objective is to generate random passwords of a specified length using a predefined set of characters.</p><pre># Import the &#39;random&#39; module to generate random characters.<br>import random</pre><p>The random library is imported to make it easier to generate random characters for the password.</p><pre># Define the set of characters that can be used to generate the password.<br>chars = &quot;abcdefghijlkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&amp;*(){}|:&lt;&gt;?/&quot;</pre><p>A string called <strong>chars</strong> is defined, which contains a collection of characters that can be utilized for generating the password. This set comprises both lowercase and uppercase letters, digits, as well as various special characters like symbols and punctuation marks.</p><pre># Prompt the user to enter the desired length of the password.<br>length = int(input(&quot;Enter length: &quot;))</pre><p>The user is asked to input the desired length of the password. The user’s input is converted into an integer and then assigned to the variable <strong>length</strong>.</p><pre># Initialize an empty string to store the generated password.<br>password = &quot;&quot;</pre><p>A variable called <strong>password</strong> is initialized as an empty string to store the generated password.</p><pre># Loop &#39;length&#39; times to build the password character by character.<br>for a in range(length):<br>    # Choose a random character from the &#39;chars&#39; set and add it to the password.<br>    password += random.choice(chars)</pre><p>The code utilizes a for loop to iterate a certain number of times, which allows it to construct the password character by character.</p><p>Within the loop, a character is randomly selected from the set of characters using the<em> random.choice(chars)</em> function. The character is subsequently appended to the password string.</p><p>The password variable stores the generated password after the loop has been completed.</p><pre># Print the generated password.<br>print(password)</pre><p>Finally, the code displays the generated password to the user.</p><p>In summary, the outcome is a simple password generator that creates random passwords according to the user’s chosen length, using a predetermined set of characters. This code is a valuable tool for generating passwords for different purposes, such as creating new accounts or configuring security settings.</p><p>Here is the complete code:</p><pre># Day 06<br># 🔐 Crafting a Simple Password Generator in Python 💡<br><br># Import the &#39;random&#39; module to generate random characters.<br>import random<br><br># Define the set of characters that can be used to generate the password.<br>chars = &quot;abcdefghijlkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&amp;*(){}|:&lt;&gt;?/&quot;<br><br># Prompt the user to enter the desired length of the password.<br>length = int(input(&quot;Enter length: &quot;))<br><br># Initialize an empty string to store the generated password.<br>password = &quot;&quot;<br><br># Loop &#39;length&#39; times to build the password character by character.<br>for a in range(length):<br>    # Choose a random character from the &#39;chars&#39; set and add it to the password.<br>    password += random.choice(chars)<br><br># Print the generated password.<br>print(password)</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*7WxyPBukfMZGwGY8lGIzOg.jpeg" /><figcaption><strong>Output — Day 06 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>Please note that this is <strong>part 1 of the password generator in Python</strong>. Part 2 of the article will provide a detailed explanation of the improved version of the password generator.</p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aadefdacc0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Python: Day 05 —  Quiz Master (Test Your Knowledge with Python)]]></title>
            <link>https://medium.com/@sumayya.malik/mastering-python-day-05-quiz-master-test-your-knowledge-with-python-ad7e4e208f34?source=rss-cb77dd3bbaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad7e4e208f34</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[100-days-of-coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-training-course]]></category>
            <category><![CDATA[python-projects]]></category>
            <dc:creator><![CDATA[Sumayyea Salahuddin]]></dc:creator>
            <pubDate>Thu, 26 Oct 2023 18:36:00 GMT</pubDate>
            <atom:updated>2023-10-31T07:52:12.101Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Python: Day 05 — 🧠 Quiz Master (Test Your Knowledge with Python)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Rqt2xT_uK7Sy1gsZxnSyA.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@unsplash?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a><strong> on </strong><a href="https://unsplash.com/photos/turned-off-macbook-pro-between-cup-of-coffee-iphone-notebook-and-pen-NuFUbftUu_s?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash"><strong>Unsplash</strong></a></figcaption></figure><p>This article provides a detailed description of <strong>Day 05 of a Python coding challenge</strong>. The following Python code is a basic quiz game that assesses the user’s knowledge. It accomplishes this by asking a sequence of questions and providing feedback based on their answers. Let us analyze the code:</p><pre># Day 05<br># 🧠 Quiz Master - Test Your Knowledge with Python!</pre><p>The comments at the beginning of the code indicate that it is a part of a coding challenge (Day 05) and its objective is to implement an interactive Python quiz game where the user is asked a series of questions, given feedback on their responses, and congratulated as the quiz champion if they answer all questions correctly.</p><pre>import random</pre><p>The first line of code imports Python’s random module that generates random numbers and simplifies program randomization. It can generate random integers, floating-point numbers, sequence items, shuffling lists, creating random seeds for repeatability, and more, making it a versatile tool for Python programs that need randomness.</p><pre># Define a list of questions and answers as tuples (question, answer)<br>qa_pairs = [ (&quot;What is 2 + 2?&quot;, &quot;4&quot;),<br>             (&quot;What is 10 * 5?&quot;, &quot;50&quot;),<br>             (&quot;What is 15 - 7?&quot;, &quot;8&quot;),<br>             (&quot;What is 30 / 3?&quot;, &quot;10&quot;),<br>             (&quot;What is 2 ** 3?&quot;, &quot;8&quot;) ]</pre><p>The list <strong>qa_pairs</strong> consists of tuples, each containing two elements: a question and its corresponding answer.</p><pre># Shuffle the question-answer pairs to get a random order<br>random.shuffle(qa_pairs)</pre><p>The function <em>random.shuffle(qa_pairs)</em> is utilized to shuffle the question-answer pairs, guaranteeing that the questions are presented in a random order.</p><pre># Initialize a variable to keep track of the score<br>score = 0</pre><p>The variable <strong>score</strong> is initialized to keep track of the user’s score.</p><pre># Iterate through the questions and ask the user<br>for question, answer in qa_pairs:<br>    print(f&quot;Question: {question}&quot;)<br>    user_answer = input(&quot;Your answer: &quot;).strip()<br>    <br>    # Check if the user&#39;s answer is correct<br>    if user_answer.lower() == answer.lower():<br>        print(&quot;Correct!\n&quot;)<br>        score += 1<br>    else:<br>        print(f&quot;Wrong! The correct answer is: {answer}\n&quot;)</pre><p>The code uses a for loop to iterate through each question-answer pair. It displays the question and prompts the user for an answer. The <em>strip()</em> method is utilized to eliminate any spaces at the beginning or end of the user’s input.</p><p>The user’s response is being compared to the correct answer. If the input matches, regardless of the case, the code will print “Correct!” and increase the score by 1. If the answers do not match, the program will print “Wrong!” and display the correct answer.</p><pre># Display the final score and congratulate the winner<br>print(f&quot;You scored {score} out of {len(qa_pairs)} questions.&quot;)</pre><p>Once all questions have been answered, the code will display the user’s final score by printing the number of correct answers out of the total number of questions.</p><pre>if score == len(qa_pairs):<br>    print(&quot;Congratulations! You are the quiz champion!&quot;)</pre><p>If the user answers all the questions correctly and their score is equal to the number of questions, the code will display a message saying “Congratulations!” You are the champion of the quiz!</p><p>To summarize, this code creates an engaging quiz experience for the user. It is designed to provide feedback based on the user’s responses and will congratulate them if they answer all the questions correctly.</p><p>Here is the complete code:</p><pre># Day 05<br># 🧠 Quiz Master - Test Your Knowledge with Python!<br><br>import random<br><br># Define a list of questions and answers as tuples (question, answer)<br>qa_pairs = [ (&quot;What is 2 + 2?&quot;, &quot;4&quot;),<br>             (&quot;What is 10 * 5?&quot;, &quot;50&quot;),<br>             (&quot;What is 15 - 7?&quot;, &quot;8&quot;),<br>             (&quot;What is 30 / 3?&quot;, &quot;10&quot;),<br>             (&quot;What is 2 ** 3?&quot;, &quot;8&quot;) ]<br><br># Shuffle the question-answer pairs to get a random order<br>random.shuffle(qa_pairs)<br><br># Initialize a variable to keep track of the score<br>score = 0<br><br># Iterate through the questions and ask the user<br>for question, answer in qa_pairs:<br>    print(f&quot;Question: {question}&quot;)<br>    user_answer = input(&quot;Your answer: &quot;).strip()<br>    <br>    # Check if the user&#39;s answer is correct<br>    if user_answer.lower() == answer.lower():<br>        print(&quot;Correct!\n&quot;)<br>        score += 1<br>    else:<br>        print(f&quot;Wrong! The correct answer is: {answer}\n&quot;)<br><br># Display the final score and congratulate the winner<br>print(f&quot;You scored {score} out of {len(qa_pairs)} questions.&quot;)<br>if score == len(qa_pairs):<br>    print(&quot;Congratulations! You are the quiz champion!&quot;)</pre><p>The output of the code is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*NLqzZBmvCFozEY3XuFcVVA.jpeg" /><figcaption><strong>Output — Day 05 Python Code</strong></figcaption></figure><p>Please visit the following GitHub Repository containing each day’s code with outputs:</p><p><a href="https://github.com/SSalahuddin/100-Days-of-Python">GitHub - SSalahuddin/100-Days-of-Python</a></p><p>If you enjoyed the article and would like to show your support, please consider:</p><p>👏 Clap for the story (100 Claps) and follow me 👉🏻<a href="https://medium.com/@sumayya.malik">Sumayyea Salahuddin</a></p><p>📑 View more content on my <a href="https://medium.com/@sumayya.malik">Medium Profile</a></p><p>🔔 Follow Me: <a href="https://medium.com/@sumayya.malik">Medium</a> | <a href="https://github.com/SSalahuddin">GitHub</a> | <a href="https://www.tiktok.com/@codecraft">TikTok</a></p><p>🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad7e4e208f34" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>