<?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 Liam on Medium]]></title>
        <description><![CDATA[Stories by Liam on Medium]]></description>
        <link>https://medium.com/@wiliz3d?source=rss-501d1da1d69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*guAHf61m60DJjaUdaK7SRg.jpeg</url>
            <title>Stories by Liam on Medium</title>
            <link>https://medium.com/@wiliz3d?source=rss-501d1da1d69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:29:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wiliz3d/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[Inverting a Binary Tree in Python: Understanding and Implementation]]></title>
            <link>https://medium.com/@wiliz3d/inverting-a-binary-tree-in-python-understanding-and-implementation-ee494483d321?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee494483d321</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[binary-tree]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 12:37:09 GMT</pubDate>
            <atom:updated>2023-08-21T12:37:09.581Z</atom:updated>
            <content:encoded><![CDATA[<p>A binary tree is a hierarchical data structure where each node has at most two children, referred to as the left child and the right child. Inverting a binary tree involves swapping the positions of the left and right children at each node, resulting in a mirror image of the original tree. This seemingly simple operation can have a profound impact on various algorithms and applications. In this article, we will explore the concept of inverting a binary tree and provide a clean implementation using Python.</p><h4>Understanding the Inversion Process</h4><p>To invert a binary tree, we traverse the tree and perform the following steps for each node:</p><ol><li>Swap the left child and the right child of the current node.</li><li>Recursively apply the inversion process to the left and right subtrees of the current node.</li></ol><p>This straightforward process effectively transforms the original tree into its inverted counterpart.</p><h4>Python Implementation</h4><p>We will start by defining a class named TreeNode to represent nodes in our binary tree. Each TreeNode object contains a value, as well as references to its left and right children.</p><pre>class TreeNode:<br>    def __init__(self, value=0, left=None, right=None):<br>        self.value = value<br>        self.left = left<br>        self.right = right</pre><p>Next, let’s implement the core function responsible for inverting the binary tree.</p><pre>def invert_tree(root):<br>    if root is None:<br>        return None<br><br>    # Swap the left and right children<br>    root.left, root.right = root.right, root.left<br><br>    # Recursively invert the left and right subtrees<br>    invert_tree(root.left)<br>    invert_tree(root.right)<br><br>    return root</pre><p>The invert_tree function follows the steps we discussed earlier. It swaps the left and right children of the current node and then recursively applies the inversion process to both subtrees.</p><p>Putting It All Together</p><p>Now that we have the TreeNode class and the invert_tree function, we can create a binary tree, invert it, and observe the results.</p><pre># Create a sample binary tree<br>root = TreeNode(1)<br>root.left = TreeNode(2)<br>root.right = TreeNode(3)<br>root.left.left = TreeNode(4)<br>root.left.right = TreeNode(5)<br><br># Invert the tree<br>inverted_root = invert_tree(root)<br><br># Function to print the tree nodes<br>def print_tree(root):<br>    if root is None:<br>        return<br>    print(root.value, end=&quot; &quot;)<br>    print_tree(root.left)<br>    print_tree(root.right)<br><br># Print the original and inverted trees<br>print(&quot;Original Tree:&quot;)<br>print_tree(root)<br>print(&quot;\nInverted Tree:&quot;)<br>print_tree(inverted_root)</pre><p>In the provided example, the original binary tree consists of nodes with values 1, 2, 3, 4, and 5. After inverting the tree, the output will display the values in the inverted order.</p><p>Conclusion</p><p>Inverting a binary tree is a fundamental operation with practical implications in various programming scenarios. Whether used in algorithms, data analysis, or software development, understanding how to implement this process can enhance your problem-solving skills. By utilizing Python and its elegant syntax, we can seamlessly apply the inversion process to binary trees and gain a deeper appreciation for the intricacies of tree structures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee494483d321" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UNDERSTANDING ASCII:]]></title>
            <link>https://medium.com/@wiliz3d/understanding-ascii-3ba3703837c2?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ba3703837c2</guid>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 09:56:09 GMT</pubDate>
            <atom:updated>2023-06-19T09:56:09.236Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner’s Guide for Computer Science Students.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uKq8f6u_D6Mzeo4j" /><figcaption>Photo by <a href="https://unsplash.com/@artturijalli?utm_source=medium&amp;utm_medium=referral">Artturi Jalli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>INTRODUCTION:</h4><p>As computer science students embark on our coding journey, we quickly encounter a fundamental concept known as ASCII. ASCII (American Standard Code for Information Interchange) is a character encoding standard that plays a crucial role in representing text in computers. This article aims to provide a comprehensive introduction to ASCII, explaining its significance and how it is used in computer science.</p><h4><strong>WHAT IS ASCII?</strong></h4><p>ASCII is a character encoding scheme that assigns unique numeric codes to represent characters. It was developed in the early days of computing to provide a standardized way of representing characters and symbols using a limited set of values. ASCII uses a 7-bit code, allowing for a total of 128 possible characters</p><h4><strong>ASCII Character Encoding:</strong></h4><p>In ASCII, each character is assigned a unique numeric value ranging from 0 to 127. For example, the ASCII code for the uppercase letter ‘A’ is 65, ‘a’ is 97, and the digit ‘0’ is 48. The ASCII table provides a complete mapping of these character codes to their corresponding characters.</p><h4><strong>ASCII and Binary Representation:</strong></h4><p>Computers operate using binary digits, or bits, which can represent either a 0 or a 1. ASCII encoding maps each character to its corresponding binary representation. For example, the ASCII code for ‘A’ (65) is represented as 01000001 in binary. This binary representation allows computers to store and process text data using numeric values.</p><h4><strong>Applications of ASCII in Computer Science:</strong></h4><p>1. Text Processing: ASCII is used extensively in text processing tasks such as input/output operations, string manipulation, and parsing. It allows computers to read, write, and manipulate text data using the encoded character representations.</p><p>2. File Formats: ASCII plays a crucial role in various file formats such as plain text files, configuration files, source code files, and more. These file formats store data in ASCII-encoded text, making them easily readable and editable.</p><p>3. Networking and Communication: ASCII is the foundation for many communication protocols, including email, FTP, HTTP, and Telnet. It ensures compatibility and consistency in exchanging textual information between different computer systems.</p><p>4. Programming Languages: ASCII is utilized by programming languages to define character literals, perform string operations, and handle user input/output. It enables programmers to work with textual data and manipulate strings efficiently.</p><h4>Conclusion:</h4><p>ASCII is an essential concept for computer science students to grasp, as it forms the basis of text representation in computers. Understanding how ASCII encodes characters and the role it plays in various computer science applications is crucial for effective programming and data manipulation. By familiarizing themselves with ASCII and its applications, students can enhance their understanding of text processing, file formats, networking, and programming languages.</p><p>As students progress in their computer science studies, they will encounter more advanced character encoding schemes, such as Unicode, which expands upon ASCII to support a broader range of characters. However, a solid understanding of ASCII provides a solid foundation and paves the way for exploring more complex character encoding systems in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba3703837c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Industrial statistics]]></title>
            <link>https://medium.com/@wiliz3d/industrial-statistics-13b72e01375f?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/13b72e01375f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistical-analysis]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Wed, 10 May 2023 22:08:04 GMT</pubDate>
            <atom:updated>2023-05-10T22:08:04.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NqqDYyRsTbvmmu5B" /><figcaption>Photo by <a href="https://unsplash.com/de/@justin_morgan?utm_source=medium&amp;utm_medium=referral">Justin Morgan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Industrial statistics is a branch of statistics that deals with the application of statistical methods to solve problems and make decisions in industrial and manufacturing settings. It involves the collection, analysis, and interpretation of data to improve processes, optimize resources, and increase efficiency and productivity. In this article, we will define statistics, discuss the types of statistics, probability theorem, types of data, and methods of data collection used in industrial statistics.</p><h3><strong>Defining </strong>Statistics:</h3><p>Statistics is the science of collecting, organizing, analyzing, interpreting, and presenting data. It provides a framework for making decisions based on data and helps to quantify and evaluate the uncertainty and variability in data. Statistics is used in a wide range of fields, including business, healthcare, economics, social sciences, and manufacturing.</p><h3>Types of Statistics:</h3><h4>There are two main types of statistics:</h4><p>Descriptive statistics and Inferential statistics.</p><p>Descriptive statistics involves summarizing and describing data using measures such as mean, median, mode, and standard deviation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*JSnx08rUlEgEFiEk2vSOEw.jpeg" /><figcaption><strong>Mean</strong>,<strong>Median</strong>,<strong>Mode</strong></figcaption></figure><p>Inferential statistics involves making inferences about a population based on a sample of data. This may involve hypothesis testing, confidence intervals, and regression analysis.</p><p>a simple example on how you can use python to do inferential statistics</p><h3>Probability Theorem:</h3><p>Probability theorem is a fundamental concept in statistics that involves the study of random events and their probabilities. The key probability theorems include the Law of Large Numbers, Bayes’ Theorem, the Central Limit Theorem, and Conditional Probability. These theorems are used to calculate probabilities and make inferences about random events.</p><h3>Types of Data:</h3><h4>There are four main types of data in statistics:</h4><p>nominal, ordinal, interval, and ratio data.</p><p>Nominal data is categorical data with no order or ranking.</p><p>Ordinal data is categorical data with a natural order or ranking.</p><p>Interval data is numerical data with equal intervals between values but no true zero point.</p><p>Ratio data is numerical data with equal intervals between values and a true zero point.</p><h3>Method of Data Collection:</h3><p>In industrial statistics, data is collected using a variety of methods, including random sampling, stratified sampling, cluster sampling, and convenience sampling.</p><p>Random sampling involves selecting a sample from the population at random.</p><p>Stratified sampling involves dividing the population into strata and selecting a sample from each stratum.</p><p>Cluster sampling involves selecting a sample of clusters and collecting data from all units within the selected clusters.</p><p>Convenience sampling involves selecting a sample based on convenience, such as selecting employees from a single department.</p><p>In conclusion, industrial statistics is an important tool for solving problems and making decisions in industrial and manufacturing settings. It involves the collection, analysis, and interpretation of data to optimize processes and increase efficiency and productivity. Understanding statistics, types of statistics, probability theorem, types of data, and methods of data collection is essential for conducting effective statistical studies in industrial and manufacturing settings.</p><p>To further expand on the topic of industrial statistics, it’s important to discuss how it’s applied in various industries. The use of statistical methods is common in manufacturing, where data is collected and analyzed to improve product quality and reduce defects. Statistical process control (SPC) is one of the most widely used techniques in manufacturing, where data is collected in real-time to monitor and control production processes.</p><p>In the field of healthcare, statistical methods are used to analyze patient data to improve medical outcomes and reduce costs. Clinical trials, which involve the testing of new drugs or medical procedures, use statistical methods to analyze data and determine the effectiveness of the treatment.</p><p>In the field of finance, statistical methods are used to analyze financial data and make predictions about market trends. Financial analysts use statistical models to forecast stock prices, analyze risk, and make investment decisions.</p><p>The field of transportation also uses statistical methods to improve efficiency and safety. Traffic flow data is collected and analyzed to optimize traffic signals and reduce congestion. Aircraft maintenance data is analyzed to identify potential problems before they lead to accidents.</p><p><strong>In Summary, </strong>industrial statistics plays a crucial role in many industries, where it’s used to collect and analyze data to improve efficiency, quality, and productivity. Understanding the different types of statistics, probability theorems, types of data, and methods of data collection is essential for conducting effective industrial statistics and making informed decisions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13b72e01375f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[INTRODUCTION TO BEAUTIFUL SOUP IN PYTHON]]></title>
            <link>https://medium.com/@wiliz3d/introduction-to-beautiful-soup-in-python-290fe0a93246?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/290fe0a93246</guid>
            <category><![CDATA[python-webscraping]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pythonpro]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 17:24:03 GMT</pubDate>
            <atom:updated>2023-03-25T17:24:03.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a-EFw0FUVYYs70_m" /><figcaption>Photo by <a href="https://unsplash.com/@der_maik_?utm_source=medium&amp;utm_medium=referral">Maik Jonietz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Beautiful Soup is a Python library that is used for web scraping purposes to extract data from HTML and XML documents. It provides a simple and easy-to-use interface for parsing and manipulating HTML and XML data.</p><p>With Beautiful Soup, you can extract data from HTML and XML documents by navigating the document tree, searching for specific tags and attributes, and extracting the contents of those tags. Beautiful Soup also provides methods for modifying and formatting HTML and XML data.</p><h3>Installing Beautiful Soup and Requests</h3><p>Before we start scraping, we need to install Beautiful Soup and Requests. You can install them using pip, a package manager for Python:</p><pre><br>pip install beautifulsoup4 requests</pre><h3>Scraping a website with Beautiful Soup and Requests</h3><p>Let’s start by scraping a simple website using Beautiful Soup and Requests. In this example, we will scrape the headlines of the BBC News website.</p><pre>import requests<br>from bs4 import BeautifulSoup<br><br># Send a GET request to the website<br>response = requests.get(&quot;https://www.bbc.com/news&quot;)<br><br># Parse the HTML content of the website<br>soup = BeautifulSoup(response.content, &quot;html.parser&quot;)<br><br># Find all the headlines on the page<br>headlines = soup.find_all(&quot;h3&quot;, class_=&quot;gs-c-promo-heading__title gel-pica-bold nw-o-link-split__text&quot;)<br><br># Print the headlines<br>for headline in headlines:<br>    print(headline.text.strip())</pre><p>In this code, we first send a GET request to the BBC News website using the Requests library. Then, we parse the HTML content of the website using Beautiful Soup. Finally, we find all the headlines on the page using the find_all method, and print them out.</p><h3>Conclusion</h3><p>Web scraping is a powerful tool for extracting data from websites. Python is a popular language for web scraping because of its simplicity, ease of use, and vast libraries. In this article, we explored how to use the Beautiful Soup and Requests libraries in Python to scrape websites. We also learned how to scrape dynamic websites using Requests. With these techniques, you can start exploring and extracting data from websites to gain insights and make data-driven decisions</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=290fe0a93246" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Random In python]]></title>
            <link>https://medium.com/@wiliz3d/random-in-python-f7b1aa418f16?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7b1aa418f16</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[pythontraining]]></category>
            <category><![CDATA[automate-python-script]]></category>
            <category><![CDATA[python-beginner]]></category>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 11:58:39 GMT</pubDate>
            <atom:updated>2023-03-25T11:58:39.354Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“How to Sort a Group of Students into Four Different Types of Groups using Python”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xUKcWsDQfVqL2ETd" /><figcaption>Photo by <a href="https://unsplash.com/@roonz_nl?utm_source=medium&amp;utm_medium=referral">RoonZ nl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplas</a>h</figcaption></figure><p>Sorting a group of students into different types of groups can be a challenging task, especially when there are a large number of students involved. However, with the help of python programming language, it becomes a relatively easy task. In this technical writing, we will discuss how to sort a group of students into four different types of groups using Python.</p><p>To sort a group of students into four different types of groups, we will be using Python’s built-in random module and the split() method. The following steps will guide us through the process:</p><h3>Step 1:</h3><p>Define the List of Students Firstly, we need to define the list of students that we want to sort into different groups. We can create a list of students by declaring a variable and assigning it to a list of names.</p><pre>import random<br><br>#Define the list of students<br><br>students = [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;,&#39;charles&#39;,&#39;wiliz&#39;,<br>            &#39;Bob&#39;, &#39;Charlie&#39;,&#39;charles&#39;,&#39;wiliz&#39;,<br>            &#39;David&#39;, &#39;Emma&#39;, &#39;liam&#39;, &#39;simi&#39;, &#39;lolu&#39;,<br>            &#39;charles&#39;,&#39;wiliz&#39;, &#39;Bob&#39;, &#39;Charlie&#39;,&#39;charles&#39;,&#39;wiliz&#39;,]</pre><h3>Step 2:</h3><p>Shuffle the List of Students Randomly, once we have defined the list of students, we will shuffle the list randomly using the random.shuffle() method. This method will shuffle the list of students in place, meaning it will modify the original list.</p><pre>#Shuffle the list of students randomly<br><br>random.shuffle(students)</pre><h3>Step 3:</h3><p>Determine the Number of Students in Each Group. After shuffling the list of students, we need to determine the number of students that should be in each group. We can do this by dividing the total number of students by four using integer division.</p><pre># Determine the number of students in each group<br><br>group_size = len(students) // 4</pre><h3>Step 4:</h3><p>Split the List of Students into Four Groups. Using a list comprehension, we can split the list of students into four groups of equal size. We will use the range() function to determine the start and end indices of each group.</p><pre># Split the list of students into 4 groups<br><br>groups = [students[i:i+group_size] <br>for i in range(0, len(students), group_size)]</pre><h3>Step 5:</h3><p>Print Out the Groups. Finally, we will print out the groups using a for loop, along with the group number and the names of the students in each group.</p><pre># Print out the groups<br><br>for i, group in enumerate(groups):<br>    print(f&quot;Group {i+1}: {&#39;, &#39;.join(group)}&quot;)</pre><pre>Output:<br>Group 1: liam, charles, Bob, wiliz, lolu<br>Group 2: Charlie, wiliz, simi, charles, wiliz<br>Group 3: charles, Bob, David, Charlie, Charlie<br>Group 4: Alice, wiliz, Bob, Emma, charles</pre><h3>Conclusion:</h3><p>Sorting a group of students into four different types of groups using Python can be achieved with just a few lines of code. By using Python’s built-in random module and the split() method, we can shuffle a list of students and split them into four groups of equal size. This technique can be applied to a wide range of scenarios where we need to divide a group of people into smaller groups. With this method, we can save time and effort, making the task of sorting a group of students more efficient and accurate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7b1aa418f16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a simple Python script that can turn an image into a piece of art using the Pillow…]]></title>
            <link>https://medium.com/@wiliz3d/creating-a-simple-python-script-that-can-turn-an-image-into-a-piece-of-art-using-the-pillow-e42c906918f6?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/e42c906918f6</guid>
            <category><![CDATA[python-help]]></category>
            <category><![CDATA[python-image-library]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 16:07:02 GMT</pubDate>
            <atom:updated>2022-12-10T16:07:02.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a simple Python script that can turn an image into a piece of art using the Pillow library:</h3><pre># Import the Image and ImageFilter modules from the Pillow library<br>from PIL import Image, ImageFilter<br><br># Import the argparse module to handle command line arguments<br>import argparse<br><br># Create an ArgumentParser object to hold the command line arguments<br>parser = argparse.ArgumentParser(description=&#39;Turn an image into art&#39;)<br><br># Add a required argument for the input file<br>parser.add_argument(&#39;input_file&#39;, help=&#39;the input image file&#39;)<br><br># Add a required argument for the output file<br>parser.add_argument(&#39;output_file&#39;, help=&#39;the output image file&#39;)<br><br># Parse the command line arguments<br>args = parser.parse_args()<br><br># Open the input image<br>input_image = Image.open(args.input_file)<br><br># Apply the BLUR filter to the image<br>blurred_image = input_image.filter(ImageFilter.BLUR)<br><br># Save the output image<br>blurred_image.save(args.output_file)</pre><p>This script uses the Pillow library to open the input image file, apply a blur filter to it, and save the resulting image to the specified output file. To use this script, you would need to pass the input and output file paths as command line arguments when running the script, for example:</p><pre>python artify.py input.jpg output.jpg</pre><p>This would take the input.jpg image, apply the blur filter to it, and save the resulting image as output.jpg.</p><p>MAKING IT MORE COMPLEX</p><pre># Import the Image, ImageFilter, and ImageEnhance modules from the Pillow library<br>from PIL import Image, ImageFilter, ImageEnhance<br><br># Import the argparse module to handle command line arguments<br>import argparse<br><br># Create an ArgumentParser object to hold the command line arguments<br>parser = argparse.ArgumentParser(description=&#39;Turn an image into art&#39;)<br><br># Add a required argument for the input file<br>parser.add_argument(&#39;input_file&#39;, help=&#39;the input image file&#39;)<br><br># Add a required argument for the output file<br>parser.add_argument(&#39;output_file&#39;, help=&#39;the output image file&#39;)<br><br># Add an optional argument for the filter to apply to the image<br>parser.add_argument(&#39;--filter&#39;, default=&#39;BLUR&#39;,<br>                    help=&#39;the filter to apply to the image&#39;)<br><br># Add an optional argument for the amount of filter to apply<br>parser.add_argument(&#39;--amount&#39;, type=float, default=1.0,<br>                    help=&#39;the amount of filter to apply&#39;)<br><br># Parse the command line arguments<br>args = parser.parse_args()<br><br># Open the input image<br>input_image = Image.open(args.input_file)<br><br># Apply the specified filter to the image<br>if args.filter == &#39;BLUR&#39;:<br>    filtered_image = input_image.filter(ImageFilter.BLUR)<br>elif args.filter == &#39;CONTOUR&#39;:<br>    filtered_image = input_image.filter(ImageFilter.CONTOUR)<br>elif args.filter == &#39;DETAIL&#39;:<br>    filtered_image = input_image.filter(ImageFilter.DETAIL)<br>elif args.filter == &#39;EDGE_ENHANCE&#39;:<br>    filtered_image = input_image.filter(ImageFilter.EDGE_ENHANCE)<br>elif args.filter == &#39;EMBOSS&#39;:<br>    filtered_image = input_image.filter(ImageFilter.EMBOSS)<br><br># Apply the specified amount of filter to the image<br>enhancer = ImageEnhance.Sharpness(filtered_image)<br>enhanced_image = enhancer.enhance(args.amount)<br><br># Save the output image<br>enhanced_image.save(args.output_file)</pre><p>This script uses the Pillow library to open the input image file, apply a specified filter to it, and save the resulting image to the specified output file. The script also allows you to specify the amount of filter to apply, using the --amount argument. To use this script, you would need to pass the input and output file paths as well as the desired filter and amount as command line arguments when running the script, for example:</p><pre>python artify.py input.jpg output.jpg --filter EMBOSS --amount 2.0</pre><p>This would take the input.jpg image, apply the emboss filter to it with an amount of 2.0, and save the resulting image as output.jpg. You can see a list of the available filters and their corresponding values by running the script with the --help argument:</p><pre>python artify.py --help</pre><p>This will display a usage message that lists the available options for the script.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e42c906918f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An intro to Threading in python]]></title>
            <link>https://medium.com/@wiliz3d/an-intro-to-threading-in-python-52064656526e?source=rss-501d1da1d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/52064656526e</guid>
            <dc:creator><![CDATA[Liam]]></dc:creator>
            <pubDate>Fri, 09 Dec 2022 19:07:32 GMT</pubDate>
            <atom:updated>2022-12-09T19:07:32.059Z</atom:updated>
            <content:encoded><![CDATA[<p>Python threading is a powerful tool that allows developers to write concurrent, parallel code in Python.<br>This means that multiple threads can execute simultaneously,allowing you to take advantage of multiple CPU cores and improve the performance of your applications.<br>In Python, threading is implemented using the threading module.</p><p>This module provides a set of classes and methods that allow you to create and manage threads in your Python code.<br>To create a thread in Python, you first need to define a new Thread class that extends the Thread class from the threading module.<br>This new class should define a run method, which specifies the code that will be executed by the thread.</p><p>For example:</p><pre>import time<br>import threading<br><br># we created a class Car<br>class Car:<br><br>    # We define the instance of Car class<br>    def __init__(self, make, model, year, color, price):<br>        self.make = make<br>        self.model = model<br>        self.year = year<br>        self.color = color<br>        self.price = price<br><br>    # We defined the detail of Car to print out out &#39;my_car&#39;<br>    def detail(self):<br>        print(f&#39;{self.make} {self.model} {self.year}  {self.model} {self.price}&#39;)<br><br># we created another class App where we implemented the thread module<br># This means that multiple threads can execute simultaneously using the &#39;class App&#39; we created<br>class App(threading.Thread):<br><br>    # we define the instance function of class App.this will help us to<br>    def __init__(self, car, counter, delay):<br>        super(App, self).__init__()<br>        self.car = car<br>        self.counter = counter<br>        self.delay = delay<br><br>   # we define a run function using a for loop<br>    def run(self):<br>        for i in range(self.counter):<br>            self.car.detail()<br>            time.sleep(self.delay)<br><br>my_car = Car(&quot;My-Car&quot;, &quot;model_number&quot;, &quot;year_released&quot;, &quot;color&quot;, &#39;The_price&#39;)<br>app_my_car = App(my_car, 5, 10)<br>app_my_car.start()<br><br>ur_car  = Car(&quot;Your-Car&quot;, &quot;model_number&quot;, &quot;year_realsed&quot;, &quot;color&quot;, &quot;The-price&quot;)<br>app_ur_car = App(ur_car, 20, 1)<br>app_ur_car.start()</pre><p>In addition to creating and starting threads, the threading module also provides a range of other tools and features for working with threads. For example, you can use the Lock class to synchronize access to shared resources between multiple threads, or the Event class to signal between threads.</p><p>Overall, Python threading is a powerful tool that can help you to improve the performance and scalability of your Python applications. By using threading, you can write concurrent, parallel code that takes advantage of multiple CPU cores.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52064656526e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>