<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason Omondi</title>
    <description>The latest articles on DEV Community by Jason Omondi (@jasonomondi).</description>
    <link>https://dev.to/jasonomondi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F815054%2F2dd2a3c9-e173-49c9-9063-3aa7c6791735.jpeg</url>
      <title>DEV Community: Jason Omondi</title>
      <link>https://dev.to/jasonomondi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jasonomondi"/>
    <language>en</language>
    <item>
      <title>Flutter State Management: Accessing Scaffold State with GlobalKey</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Wed, 02 Aug 2023 09:52:00 +0000</pubDate>
      <link>https://dev.to/jasonomondi/flutter-state-management-accessing-scaffold-state-with-globalkey-489k</link>
      <guid>https://dev.to/jasonomondi/flutter-state-management-accessing-scaffold-state-with-globalkey-489k</guid>
      <description>&lt;p&gt;In &lt;a href="https://docs.flutter.dev/"&gt;Flutter&lt;/a&gt;, a widget's &lt;strong&gt;"scope"&lt;/strong&gt; refers to its enclosing widget tree and the context in which it is defined. While a widget can access properties and methods of its immediate parent and itself, accessing widgets higher up (&lt;strong&gt;ancestors&lt;/strong&gt;) or lower down (&lt;strong&gt;descendants&lt;/strong&gt;) in the tree can be challenging.&lt;/p&gt;

&lt;p&gt;In certain scenarios, you may encounter situations where you need to interact with a widget outside your current scope. For instance, you might want a button in a child widget to trigger an action in its parent or activate a function in a deeply nested widget that affects a top-level widget.&lt;/p&gt;

&lt;p&gt;For such cases, the &lt;code&gt;Scaffold&lt;/code&gt; widget plays a pivotal role. It offers methods like &lt;code&gt;openDrawer()&lt;/code&gt;, &lt;code&gt;showSnackBar()&lt;/code&gt;, etc., which control its behavior and perform scaffold-related actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyWidget&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;GlobalKey&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ScaffoldState&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_scaffoldKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GlobalKey&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ScaffoldState&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;key:&lt;/span&gt; &lt;span class="n"&gt;_scaffoldKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// ... rest of the widget ...&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Case
&lt;/h2&gt;

&lt;p&gt;In a recent scenario, I utilized the &lt;code&gt;_scaffoldKey&lt;/code&gt; to render a &lt;a href="https://docs.flutter.dev/cookbook/design/drawer"&gt;&lt;code&gt;drawer&lt;/code&gt;&lt;/a&gt;. In Flutter's architecture, the Scaffold widget employs a &lt;code&gt;GlobalKey&lt;/code&gt; to manage and control its state. The &lt;code&gt;GlobalKey&amp;lt;ScaffoldState&amp;gt;&lt;/code&gt; is &lt;strong&gt;indispensable&lt;/strong&gt; when you must access scaffold widget properties and methods beyond its immediate scope.&lt;/p&gt;

&lt;p&gt;My specific case involved opening the &lt;code&gt;drawer&lt;/code&gt; from a child widget, where the drawer resided at the &lt;strong&gt;top level of the widget&lt;/strong&gt; tree—beyond the child's scope. To achieve this, I needed a way to access the &lt;code&gt;ScaffoldState&lt;/code&gt; of the Scaffold widget.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here's a breakdown of the process:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Upon defining a &lt;strong&gt;Scaffold widget&lt;/strong&gt;, it generates a &lt;code&gt;ScaffoldState&lt;/code&gt; object that encapsulates the current scaffold state.&lt;/li&gt;
&lt;li&gt;To access the scaffold's state, you need a reference to the &lt;code&gt;ScaffoldState&lt;/code&gt; object. This is where the &lt;code&gt;GlobalKey&amp;lt;ScaffoldState&amp;gt;&lt;/code&gt; proves invaluable.&lt;/li&gt;
&lt;li&gt;By defining a &lt;code&gt;GlobalKey&amp;lt;ScaffoldState&amp;gt;&lt;/code&gt;, you can associate it with the Scaffold widget using the key property. This establishes a link to the &lt;code&gt;ScaffoldState&lt;/code&gt; within the &lt;strong&gt;Scaffold widget&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Upon tapping the menu icon (housed in a GestureDetector within the child widget), we invoke the &lt;code&gt;openDrawer()&lt;/code&gt; method on the &lt;code&gt;ScaffoldState&lt;/code&gt; obtained from &lt;code&gt;_scaffoldKey&lt;/code&gt;. This action triggers the opening of the &lt;strong&gt;drawer&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;GestureDetector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;onTap:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_scaffoldKey&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;currentState&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;openDrawer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;menu&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, leveraging &lt;code&gt;_scaffoldKey&lt;/code&gt; with &lt;code&gt;GlobalKey&amp;lt;ScaffoldState&amp;gt;&lt;/code&gt; furnishes us with a mechanism to engage with the Scaffold widget and access its state from a child widget. This capability proves pivotal for executing actions such as drawer opening, snack bar presentation, bottom sheet display, and more—actions that mandate interaction with the Scaffold widget from the child widget's contextual domain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lKHhSLEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7hwn2mph2hzdny2ovk7.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lKHhSLEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7hwn2mph2hzdny2ovk7.PNG" alt="Image description" width="326" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember, this technique empowers you to extend your widget's reach and enables seamless communication and interaction across different parts of your widget tree in Flutter.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Detecting Fake News with Python and Machine Learning.</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Sat, 30 Apr 2022 17:49:33 +0000</pubDate>
      <link>https://dev.to/jasonomondi/detecting-fake-news-with-python-and-machine-learning-d8c</link>
      <guid>https://dev.to/jasonomondi/detecting-fake-news-with-python-and-machine-learning-d8c</guid>
      <description>&lt;p&gt;Hi 👋! Nice to meet you devs 😄. Here, we will talk about how we can use python to detect fake news. This article aims to walk you through the process of creating a machine learning model using python and NLP to successfully detect fake news.&lt;br&gt;
You will need to know the fundamentals of Python, data structures and algorithms, python libraries such as Pandas, NumPy, and Methods in Data Analysis for example Passive Aggressive Classifiers.&lt;/p&gt;
&lt;h1&gt;
  
  
  Key Terms
&lt;/h1&gt;

&lt;p&gt;• TfidfVectorizer&lt;br&gt;
• IDF (Inverse Document Frequency)&lt;br&gt;
• TF (Term Frequency)&lt;br&gt;
• Passive Aggressive Classifier&lt;/p&gt;

&lt;p&gt;Preparing our dataset and work environment&lt;br&gt;
First, we need to install a supported version of python. To do so, you can go to your browser and search ‘download python 3’ and then install after downloading. This will vary with the type of Operating system you will be using on your machine.&lt;br&gt;
Dataset&lt;br&gt;
Acquiring a suitable dataset presents one of the most crucial components of any data-science endeavor. These Data sets can be accessed on the Kaggle website.&lt;/p&gt;
&lt;h1&gt;
  
  
  Coding
&lt;/h1&gt;

&lt;p&gt;Now after installing python, the libraries, and the dataset too, it is time to launch our text editors (you can use Jupyter notebook) and begin importing the libraries you need. We can now view the first four records. Using Python, we can see that the data-set is divided into the following columns: id, title, author, text, and label. The features that are of interest to us are the label and text columns. The text column contains the contents of the article, whereas the label column represents whether the article is factual or not. This has been pre-made for us in binary form using ‘1’(‘REAL’) and ‘0’(‘FAKE’).&lt;br&gt;
The PassiveAggressiveClassifier is to now be initialized in order to incorporate it into the model, we are going to use the “y_train” and “tfidf_train”.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Initialize the PassiveAggressiveClassifier and fit training sets
&lt;/h3&gt;


&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pa_classifier=PassiveAggressiveClassifier(max_iter=50)
pa_classifier.fit (tfidf_train, y_train)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Finally, using the vectorizer you can predict whether an article is reliable or not and we are going to calculate our model’s accuracy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Predict and calculate accuracy
&lt;/h3&gt;


&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y_pred=pa_classifier.predict(tfidf_test)
score=accuracy_score(y_test, y_pred)
print(f'Accuracy: {round(score*100,2)} %')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can now see the accuracy the model had while conducting its tests. Although you view the accuracy, you might not know the number of successful predictions and failures. In order to access such information, you can use a confusion matrix and draw conclusions. This can be easily done by:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Build confusion matrix
&lt;/h3&gt;


&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;confusion_matrix(y_test, y_pred, labels=['FAKE','REAL'])&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion.
&lt;/h1&gt;

&lt;p&gt;It is essential that such models are further advanced in order to effectively combat misinformation in these difficult times.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Ultimate Python Tutorial for Beginners</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Sun, 24 Apr 2022 06:34:15 +0000</pubDate>
      <link>https://dev.to/jasonomondi/the-ultimate-python-tutorial-for-beginners-4iop</link>
      <guid>https://dev.to/jasonomondi/the-ultimate-python-tutorial-for-beginners-4iop</guid>
      <description>&lt;p&gt;Hi 👋! &lt;br&gt;
We are going to tackle the following topics in Python briefly, just to help you catch a glimpse of what you are going to face when you start using Python.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Introduction &lt;/li&gt;
&lt;li&gt;Variables and datatypes in Python&lt;/li&gt;
&lt;li&gt;Operators in Python&lt;/li&gt;
&lt;li&gt;Control structures&lt;/li&gt;
&lt;li&gt;Arrays&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python is a high-level programming language that is used for educational purposes and also to solve real-world IT-related problems.&lt;br&gt;
It is considered to be a very easy language to learn, understand and implement. If you are hearing of programming for the first time and you want to unleash your programming passion, this is yours to go language. If on the other hand, you have been in the field for a long time, you will grasp Python very quickly, and with no time you are doing wonders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fun facts about Python
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;It is a popular language applied across to solve various IT problems. So you won’t be wasting your time learning Python.&lt;/li&gt;
&lt;li&gt;It has a very simple syntax therefore you will never be intimidated about how to maneuver around as you develop your application.&lt;/li&gt;
&lt;li&gt;With the simple syntax in play, you don’t have to have numerous classes or pages of code in your application for it to be called a serious application. Just a few working lines and you have solved a huge problem.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Various IDEs used for coding Python&lt;/em&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;PyCharm (IDE) – it was developed by JetBrains and it’s supported by Windows, Linux, and macOS Operating systems.&lt;/li&gt;
&lt;li&gt;Sublime text (Text editor) – it is a generic text editor for a variety of languages and is super simple to use. It is fast and helps in debugging code efficiently. It’s supported by Windows, Linux, and macOS Operating systems.&lt;/li&gt;
&lt;li&gt;Visual Studio Code (IDE) – it is a powerful code management engine that was developed by Microsoft for platforms like Windows, Linux, and macOS Operating systems.&lt;/li&gt;
&lt;li&gt;Vim (Text Editor) – it provides a good user experience when coding and is enriched with different features that aid in development.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Variables and Datatypes in Python
&lt;/h2&gt;

&lt;p&gt;We have talked about the simplicity of Python. Now at this point, we start to explore the first simple fact about Python.&lt;br&gt;
We do not explicitly declare variables with their data types. Python assigns a data type depending on the data you are assigning that variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type of variables
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Local variables – these are those used inside a function or a method &lt;/li&gt;
&lt;li&gt;Global variables – are used when you want to use a variable on the entire program.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;The various data types are:&lt;/em&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Integer – for storing numerical values, wholes number&lt;/li&gt;
&lt;li&gt;Floating point – for storing decimal numbers &lt;/li&gt;
&lt;li&gt;Strings – for storing text or any data that is enclosed using double quotes (“ ”).&lt;/li&gt;
&lt;li&gt;Booleans – this stores either true or false depending on what an expression will return.
There are other data types that may be a bit advanced though for  now we can focus on understanding these fundamentals.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Operators in Python
&lt;/h2&gt;

&lt;p&gt;Operators are simply actions or processes that instruct the compiler on what to do on a predefined set of data.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Types of operators&lt;/em&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Arithmetic operators &lt;/li&gt;
&lt;li&gt;Assignment operators&lt;/li&gt;
&lt;li&gt;Comparison operators &lt;/li&gt;
&lt;li&gt;Logical operators
Most likely you will encounter scenarios that will require you to use either of these types of operators stated above. Let’s have a brief insight into each of them.&lt;/li&gt;
&lt;li&gt;Arithmetic operators – these operators are used to perform basic mathematical operations.
They include: -  +,-,*, /, % 
&lt;/li&gt;
&lt;li&gt;Assignment operators – from the name you can already understand the role of these operators. 
They are used to assign values to the variables. 
They include: -  ==, -=, +=, =, ++, --, /=, %=, *= 
&lt;/li&gt;
&lt;li&gt;Comparison operators – these operators are used on two values and they return a Boolean value that is either true or false.
They include: -  ==, &amp;lt;, &amp;gt;, &amp;gt;=, &amp;lt;=, != 
&lt;/li&gt;
&lt;li&gt;Logical operators – their operators are used to combine values that result in Boolean values.
They include: -  AND, OR, NOT 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Control Structures in Python
&lt;/h2&gt;

&lt;p&gt;The three different types of control structures are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selection&lt;/li&gt;
&lt;li&gt;Sequential&lt;/li&gt;
&lt;li&gt;Repetition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are going to briefly get an insight into the three structures and try to understand their role in python programming.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;em&gt;Selection&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt; – this structure allows you to make decisions based on a particular criterion.&lt;br&gt;
You can use the following statement to archive this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If statements – for at least one condition&lt;/li&gt;
&lt;li&gt;If else statements – for at least two conditions&lt;/li&gt;
&lt;li&gt;If else if statements – for more than two conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;em&gt;Sequential&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt; – this is whereby you have to execute an instruction before going to the next set of instructions. For example, finding an average of marks, you have to get the total marks and then divide by the number of subjects or units.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;em&gt;Repetition&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt; – this requires that a certain code is repeated until a predefined condition is met.&lt;br&gt;
The statements used to archive this control structure are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;While… loop&lt;/li&gt;
&lt;li&gt;Nested loop&lt;/li&gt;
&lt;li&gt;For loop&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Arrays in Python
&lt;/h2&gt;

&lt;p&gt;An array is just basically a  collection of a set of data with the same characteristics as the data type.&lt;br&gt;
They are used to store multiple values in one single variable.&lt;br&gt;
Arrays use an index to access the elements at a specific position. The indexes start from 0 which is equivalent to element 1. &lt;br&gt;
The only difference with normal variable naming is that you include a square bracket ([ ]).&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python for Everyone: Mastering python the right way.</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Mon, 28 Feb 2022 21:48:03 +0000</pubDate>
      <link>https://dev.to/jasonomondi/python-for-everyone-mastering-python-the-right-way-34nc</link>
      <guid>https://dev.to/jasonomondi/python-for-everyone-mastering-python-the-right-way-34nc</guid>
      <description>&lt;p&gt;Mastering anything takes time and adequate practice. Like any other programming language, for you to fully understand python as a programming language, you need to practice a lot.&lt;br&gt;
Learning how to program is different from actually understanding what is going on and why you do what you do on different scenarios.&lt;br&gt;
Before we start off I would like to give you a little secret that will help you grow in programming. When you are comfortable with the syntax of a language and you have gone through all the basics of the language, start on a serious application from scratch (not templates) and try to consolidate all the knowledge you have acquired and develop the application.&lt;br&gt;
With this approach there are a lot of things that you will learn as you develop which may not be covered in the basics. By the time you are done with the application you will be bubbling experience enough to secure you a job.&lt;br&gt;
We are going to tackle a few fields just to enlighten you on some advanced topics.&lt;br&gt;
     •    Naming conventions&lt;br&gt;
     •    Error handling exceptions&lt;br&gt;
     •    Documenting code&lt;br&gt;
     •    Unit testing &lt;br&gt;
     •    Refactoring &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 1. Naming conventions 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;These are rules that a programmer follows when naming the objects and variables when programming.&lt;br&gt;
You need to choose one naming convention and use it in the entire application. It is highly discouraged to use different conventions because of confusions.&lt;br&gt;
They make the code readable to the programmer and also the reviews or people who will manage the code later when you are gone.&lt;br&gt;
Examples:&lt;br&gt;
     -   Camel case – this is where the first letter of the word starts with capital a letter and in case of other words in the name they also start with a capital letter e.g. StudentName = ‘Alvin’ or Student_Name.&lt;br&gt;
     -  Pascal notation - the first word starts with a small letter and if there are words they start with capital letters e.g. studentName = ‘Alvin’ or student_Name.&lt;/p&gt;

&lt;p&gt;You can also come up with your own convention which is suitable for you but make sure it is consistent throughout your code.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 2. Error handling exceptions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Error handling is just taking care of errors that might occur during usage of the application.&lt;br&gt;
There are a lot or exceptions that can occur and cause the application to crush if not dealt with appropriately.&lt;br&gt;
One thing a programmer should know and understand well is writing code in a way that most of the errors will never occur in the application. For example if a user is required to enter an integer as input, you first ascertain that it’s the right data type then proceed else provide a meaningful error message to the user.&lt;br&gt;
As you proceed you will learn on how to navigate through and make sure that your application is very stable and reliable.&lt;br&gt;
Exceptions are basically logical errors that occur during runtime of the application. Examples of the exceptions are: &lt;br&gt;
     •    ImportError – occurs when the imported module is not found.&lt;br&gt;
     •    IndexError – occurs when index is out of range mostly in arrays &lt;br&gt;
     •    SyntaxError – occurs when a syntax error is encountered in the code.&lt;br&gt;
     •    OverFlowError – occurs when a result of an arithmetic operation is too large to be represented given the data type.&lt;br&gt;
These are just but a few exceptions. When developing an application try to understand as many exceptions as you can and find ways to mitigate them and the end results will be fantabulous.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 3. Documenting code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you develop an application there is always that part where you have to write very complex code to achieve a certain goal.&lt;br&gt;
A writer once said that the code you write today may be as clear as mad tomorrow even to you. &lt;br&gt;
To make sure that we write code and understand it in 20 years to come, I will highly recommend that you document you code when necessary.&lt;br&gt;
By documenting I mean this, write comments above lines of code that you think needs some explanation. This will come in handy when you are not available and someone else is managing your code. They will tend to understand it more quickly and make their life easy.&lt;br&gt;
Commenting out a line you start with a ‘#’ sign and the compiler will ignore that line during execution.&lt;br&gt;
Example: # This piece of code is computing the net salary of an employee by getting the total tax, deducting NHIF, NSSF from the gross salary.&lt;br&gt;
In days to come, with the first glance of the code you will be already understanding it and maintaining it with no itches at all.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 4. Unit testing 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is a process where small portions or functions are tested individually in order to ascertain that they give legitimate results with different set of values.&lt;br&gt;
Any application that is developed and is supposed to operate in the business world needs a lot of testing. Tests expose short comings of an application before it reaches production stage.&lt;br&gt;
In order to achieve unit testing, a programmer should embrace the separation of concerns. This is where each class or function does one thing only. With this it’s easier to test each function and with all the possible set of results, approve that the function works correctly.&lt;br&gt;
Python has a module (unittest) which helps in testing.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 5. Refactoring 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is where a programmer goes through the code and try to make changes based on newly learned concepts or reducing code in either way.&lt;br&gt;
When you are writing code most if not all upcoming programmers tend to use very long ways to achieve something. It is accepted and it is not a sin. When now you sit down later and try to read your own code after some exposure you will release that there are approaches that you made which are relatively long.&lt;br&gt;
The act of changing code to simpler versions or just changing the logic is called refactoring.&lt;br&gt;
The changes can be made increase performance of maybe some queries, stability of the application and also to reduce complexity or lines of code.&lt;br&gt;
The main benefit of code refactoring is to help clean up dirty code so as to reduce the technical debt.&lt;br&gt;
 A technical debt is a basically the rework on an application that was already in production due to instability or low performance.&lt;br&gt;
When you write code try to take it to a reviewer who has higher experience who will point out shortcomings and help you reduce the technical debt.&lt;br&gt;
These is just but a few things that one should look out after learning python programming. This will help develop industry grade applications with minimal or no technical debt.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms With Python.</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Mon, 21 Feb 2022 10:33:58 +0000</pubDate>
      <link>https://dev.to/jasonomondi/introduction-to-data-structures-and-algorithms-with-python-3a4i</link>
      <guid>https://dev.to/jasonomondi/introduction-to-data-structures-and-algorithms-with-python-3a4i</guid>
      <description>&lt;p&gt;&lt;em&gt;Python&lt;/em&gt; is a programming language that is taking over the market. It is very essential for you to learn its ways of storing and manipulating data for a smooth programming experience.&lt;br&gt;
You should be able to appreciate by the end of this article that data structures are very powerful and can be used to solve very complex problems in the world of computing.&lt;br&gt;
Let’s hop right into it. So Data structures are just ways or means of storing data such that operations can be done on the data which is stored in computers more efficiently.&lt;br&gt;
On the other hand Algorithms are step by step instructions of how to solve a particular problem.&lt;/p&gt;

&lt;p&gt;We are going to discuss the following structures:&lt;br&gt;
     •    Lists &lt;br&gt;
     •    Dictionaries &lt;br&gt;
     •    Tuples&lt;br&gt;
     •    Sets&lt;br&gt;
     •    Queues&lt;br&gt;
     •    Stack&lt;br&gt;
     •    Linked lists&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lists&lt;/strong&gt;&lt;br&gt;
These are just ordered collections of data that are stored together in the same variable. It sounds similar to arrays.&lt;br&gt;
The basic syntax of declaring a list is by enclosing the list elements in square brackets&lt;br&gt;
Example: name  = [1,2,3,4,5…]&lt;br&gt;
The elements in the list can be accessed through indexes. The index counts from 0 which is the first element in the list all the way to N-1 where N is the total number of elements in the list.&lt;br&gt;
There are operations that are made to the list and we are going to briefly state them as follows:&lt;br&gt;
     -  Append – adds elements to the end of the list&lt;br&gt;
     -  Remove – removes elements from the list in case of two &lt;br&gt;
                 occurrences of the same element&lt;br&gt;
     -  Pop – removes elements at any position on the list&lt;br&gt;
     -  Insert – adds elements at any position on the list&lt;br&gt;
     -  Len – returns the length of the list i.e. number of items&lt;br&gt;
These are just but a few but in case you want to advance to more complex operations you can refer to articles on the web. We are trying to be as basic as possible so as not to intimidate newbies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dictionaries&lt;/strong&gt; &lt;br&gt;
These are collections of data values that uses a key and a value to store the data. It is unlike other data types that store same collections of data in the sense that it uses the key: value pair in it storage.&lt;br&gt;
The keys are case sensitive in the sense that ‘Myname’ as a key is different from ‘myName’.&lt;br&gt;
The keys can never be duplicated, it can only appear once in the dictionary.&lt;br&gt;
Values can be repeated and of any data type, it causes no harm.&lt;br&gt;
This is the syntax for a dictionary in python: name = {1: ‘Nairobi’, 2: ‘Kampala’, 3: ‘Arusha’…}&lt;br&gt;&lt;br&gt;
You can straight away realize the difference between dictionary and a list is the square brackets and the curly brackets.&lt;br&gt;
Operations on the dictionary in python&lt;br&gt;
These are a handful of operations that can be used:&lt;br&gt;
     1. Update items&lt;br&gt;
     2. Copy items&lt;br&gt;
     3. Get values from  the dictionary&lt;br&gt;
     4. Clear the dictionary&lt;br&gt;
     5. Get the keys that are on the dictionary&lt;br&gt;
There are other operations so don’t be confined to these few which are just meant to enlighten you about basic information about data structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tuples&lt;/strong&gt;&lt;br&gt;
It is also a collection but now of pythons objects that are comma separated and they are stored in an ordered sequence. It is also immutable in the sense that it doesn’t change.&lt;br&gt;
The syntax of declaring a tuple is : variableName = (‘Nairobi’, ‘Kisumu’, ‘Mombasa’… )&lt;br&gt;
Tuples can be joined together and the data in them printed together. This is called Concatenation. &lt;br&gt;
You just use the ‘+’ sign to join to tuples together i.e. tuple1 + tuple2.&lt;br&gt;
Operations on the tuple in python&lt;br&gt;
The items in the tuple can be:&lt;br&gt;
     -  Deleted &lt;br&gt;
     -  Updated&lt;br&gt;
     -  You can get length of the tuple&lt;br&gt;
     -  Perform repetition of items&lt;br&gt;
     -  Loop through the items&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sets&lt;/strong&gt;&lt;br&gt;
Like lists, sets are used to store multiple items or a collection of data in a single variable.&lt;br&gt;
Items in a set are usually unordered, unindexed, and immutable.&lt;br&gt;
The basic syntax is the same as that of the dictionary. We use curly brackets to define the values or items in the set.&lt;br&gt;
Duplicates are not allowed in a set. Also it can accept a wide range of data types.&lt;br&gt;
Syntax: variableName= {‘Nairobi’, ‘Naivasha’, ‘Nakuru’…}&lt;br&gt;
Operations on the set in python&lt;br&gt;
     -  Union – this is used to get a new set of elements from two &lt;br&gt;
        sets which are being joined.&lt;br&gt;
     -  Intersection – returns elements that are common to two &lt;br&gt;
        sets&lt;br&gt;
     -  Difference – returns items that are in the first set and &lt;br&gt;
        not in the second set&lt;br&gt;
     -  Symmetric difference – returns a set containing elements &lt;br&gt;
        in both sets but exclude the common ones.&lt;br&gt;
     -  You can also copy, clear, add and remove in a set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Queues&lt;/strong&gt;&lt;br&gt;
These are linear data structures that store there item in FIFO (First In First Out). This means that the least recent item to be added to the queue will be the first to be removed.&lt;br&gt;
Because of the linear feature, they don’t allow random access of items from any position.&lt;br&gt;
You can implement a queue in python using lists, collections.deque or queue.Queue.&lt;br&gt;
Operations on the queue in python&lt;br&gt;
These are the operations that can be made on a queue:&lt;br&gt;
     -  Enqueue - this operation adds items to the queue.&lt;br&gt;
     -  Dequeue – it removes items from the queue where by the &lt;br&gt;
        items are popped out in the same order which they were &lt;br&gt;
        pushed in.&lt;br&gt;
     -  Front – it gets the item at the front of the queue.&lt;br&gt;
     -  Rear – gets the last item from the queue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stacks&lt;/strong&gt;&lt;br&gt;
It is also a linear data structure but now this can store its items either in LIFO (Last In First Out) or FILO (First In Last Out).&lt;br&gt;
The last item or the first item to be added can be first to be accessed for manipulation. If an element is added from a specific end, it will only be accessed through that end.&lt;br&gt;
The implementation of stacks is basically the same as queues.&lt;br&gt;
Operations on the stack in python&lt;br&gt;
     -  Push – it inserts elements to a stack&lt;br&gt;
     -  Pop – it delete elements from a stack&lt;br&gt;
     -  Top – returns a reference to the topmost element in the &lt;br&gt;
        stack.&lt;br&gt;
     -  Empty – it checks if the stack is empty or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linked lists&lt;/strong&gt;&lt;br&gt;
These are collections or sequence of data elements that are connected together via links.&lt;br&gt;
The links are inform of pointers, which link every element to another element.&lt;br&gt;
With linked list it is easy to perform insertion and deletion operations because of the pointers.&lt;br&gt;
However due to the pointers being in the picture, they have to be stored therefore you end up with double storage on a single element. You can also not access the elements randomly cause of the linear feature.&lt;br&gt;
They can also store any data type.&lt;br&gt;
In python linked lists are created using the node class which can be manipulated effectively.&lt;br&gt;
Types of linked lists&lt;br&gt;
     1. Singly linked list –  contains only a link to the next &lt;br&gt;
        element&lt;br&gt;
     2. Doubly linked list – contains a link to the next and &lt;br&gt;
        previous elements&lt;br&gt;
     3. Circular linked list – all the nodes are connected to &lt;br&gt;
        forma circle.&lt;br&gt;
Operations on the linked list in python&lt;br&gt;
     -  Insert items to the list&lt;br&gt;
     -  Delete items&lt;br&gt;
     -  You can print the list out&lt;br&gt;
     -  Get the size of the list&lt;br&gt;
     -  You can search a given element from the list&lt;br&gt;
     -  Traverse the nodes one after the other&lt;br&gt;
     -  Sort the list&lt;/p&gt;

</description>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>A BASIC PYTHON BEGINNERS GUIDE</title>
      <dc:creator>Jason Omondi</dc:creator>
      <pubDate>Mon, 14 Feb 2022 15:07:27 +0000</pubDate>
      <link>https://dev.to/jasonomondi/a-basic-python-beginners-guide-4ep2</link>
      <guid>https://dev.to/jasonomondi/a-basic-python-beginners-guide-4ep2</guid>
      <description>&lt;p&gt;Hi! &lt;br&gt;
We are going to tackle the following topics in Python briefly, just to help you catch a glimpse of what you are going to face when you start using Python.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Introduction&lt;/li&gt;
&lt;li&gt; Variables and datatypes in Python&lt;/li&gt;
&lt;li&gt; Operators in Python&lt;/li&gt;
&lt;li&gt; Control structures&lt;/li&gt;
&lt;li&gt; Arrays&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;i.  Introduction &lt;br&gt;
Python is a high-level programming language that is used for educational purposes and also to solve real world IT related problems.&lt;br&gt;
It is considered to be a very easy language to learn, understand and implement. If you are hearing of programming for the first time and you want to unleash your programming passion, this is your to go language. If on the other hand you have been on the field for a long time, you will grasp Python very quickly and with no time you are doing wonders.&lt;br&gt;
Fan facts about Python&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  It is a popular language applied across to solve various IT problems. So you won’t be wasting your time learning Python.&lt;/li&gt;
&lt;li&gt;  It has a very simple syntax therefore you will never be intimidated about how to maneuver around as you develop your application.&lt;/li&gt;
&lt;li&gt;  With the simple syntax in play, you don’t have to have numerous classes or pages of code in your application for it to be called a serious application. Just few working lines and you have solved a huge problem. Brains and it’s supported by Windows, Linux and MacOS Operating systems.&lt;/li&gt;
&lt;li&gt;  Sublime text (Text editor) – it is a generic text editor for variety of language and super simple to use. It is fast and helps in debugging of code efficiently. It’s supported by Windows, Linux and MacOS Operating systems.&lt;/li&gt;
&lt;li&gt;  Visual Studio Code (IDE) – it is a powerful code management engine that was developed by Microsoft for platforms like Windows, Linux and MacOS Operating systems.&lt;/li&gt;
&lt;li&gt;  Vim(Text Editor) – it provides a good user experience when  coding and enriched with different features that aid in development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ii. Variables and Datatypes in Python&lt;br&gt;
We have talked about the simplicity of Python. Now at this point we start to explore the first simple fact about Python.&lt;br&gt;
We do not explicitly declare variables with their datatypes. Python assigns a datatype depending with the data you are assigning that variable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Type of variables 
Local variables – these are those used inside a function or a method 
Global variables – they are used when you want to use a variable on the entire program.
The various datatypes are: &lt;/li&gt;
&lt;li&gt;   Integer – for storing numerical values, wholes number&lt;/li&gt;
&lt;li&gt;  Floating point – for storing decimal numbers &lt;/li&gt;
&lt;li&gt;  Strings – for storing text or any data that is enclosed using double quotes (“ ”).&lt;/li&gt;
&lt;li&gt;  Booleans – this stores either true or false depending on what an expression will return.
There are other datatypes that maybe a bit advanced for beginners but will be tackled later.
iii.    Operators in Python
Operators are simply actions or process that instruct the complier on what to do on a predefined set of data.
Types of operators &lt;/li&gt;
&lt;li&gt;  Arithmetic operators &lt;/li&gt;
&lt;li&gt;  Assignment operators&lt;/li&gt;
&lt;li&gt;  Comparison operators &lt;/li&gt;
&lt;li&gt;  Logical operators
Most likely you will encounter scenarios that will require you to use either of these types of operators stated above. Let’s have a brief insight about each of them.&lt;/li&gt;
&lt;li&gt;  Arithmetic operators – these operators are used to perform basic mathematical operations.
They include: - +,-,*, /, %&lt;/li&gt;
&lt;li&gt;  Assignment operators – from the name you can already understand the role of these operators. 
They are used to assign values to the variables. 
They include: - ==, -=, +=, =, ++, --, /=, %=, *=&lt;/li&gt;
&lt;li&gt;  Comparison operators – these operators are used on two values and they return a Boolean value which is either true or false.
They include: - ==, &amp;lt;, &amp;gt;, &amp;gt;=, &amp;lt;=, !=&lt;/li&gt;
&lt;li&gt;  Logical operators – there operators are used to combine values that result into Boolean values.
They include: - AND, OR, NOT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;iv. Control structures in Python&lt;br&gt;
The three different types of control structures are: - Selection, sequential, repetition.&lt;br&gt;
We are going to briefly get an insight on the three structure and try to understand their role in python programming.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Selection – this structure allows you to take decisions based on a particular criteria.
You can used the following statement to archive this:&lt;/li&gt;
&lt;li&gt; If statements – for at least one condition&lt;/li&gt;
&lt;li&gt; If else statements – for at least two conditions&lt;/li&gt;
&lt;li&gt; If else if statements – for more than two conditions&lt;/li&gt;
&lt;li&gt;  Sequential – this is where by you have to execute an instruction before going to the next set of instructions. Example finding an average of marks, you have to get the total marks then divide by the number of subjects or units.&lt;/li&gt;
&lt;li&gt;  Repetition – this requires that a certain code is repeated until a predefined condition is met.
The statements used to archive this control structure are:&lt;/li&gt;
&lt;li&gt; While… loop&lt;/li&gt;
&lt;li&gt; Nested loop&lt;/li&gt;
&lt;li&gt; For loop&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt; Arrays in python 
An array is just basically a collection of a set of data with the same characteristics like the datatype.
They are used to store multiple values in one single variable.
Arrays use an index to access the elements at the specific position. The indexes start from 0 which is equivalent to element 1. 
The only difference with normal variable naming is that you include a square bracket ([ ]).&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
  </channel>
</rss>
