<?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: Flavian Kyande</title>
    <description>The latest articles on DEV Community by Flavian Kyande (@flaviankyande).</description>
    <link>https://dev.to/flaviankyande</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%2F811643%2Fb9a76e23-e9ef-4440-9934-a2b2d3e126c4.jpg</url>
      <title>DEV Community: Flavian Kyande</title>
      <link>https://dev.to/flaviankyande</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flaviankyande"/>
    <language>en</language>
    <item>
      <title>Python for everyone: Mastering Python The Right Way</title>
      <dc:creator>Flavian Kyande</dc:creator>
      <pubDate>Fri, 04 Mar 2022 07:33:39 +0000</pubDate>
      <link>https://dev.to/flaviankyande/python-for-everyone-mastering-python-the-right-way-3kh6</link>
      <guid>https://dev.to/flaviankyande/python-for-everyone-mastering-python-the-right-way-3kh6</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1RL8JmVl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2At7HBQb9hPzEOjoyy" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1RL8JmVl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2At7HBQb9hPzEOjoyy" alt="_Photo by Iewek Gnos on Unsplash_" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learning has to be comfortable to you for you to succeed, and we all have different methods of learning which each of us swears to. I am in no way discrediting any methods of studying, I am only giving my opinion after various trial and error stages in the hope of helping like-minded people succeed in their paths. I hope you enjoy this article and the comment section is always free and open for us to share ideas on this topic.&lt;/p&gt;

&lt;p&gt;In December 2021, I made a resolution that I will be learning Python to add it to my stack of programming languages. Fast track to today, I can say that I’m in a better place than where I was three months ago. Am I a pro Pythonista now? That’s a big call for sure, I am still very far from achieving my Python programming goals, but I can say, I have grasped some fundamentals. Now I can lay out a simple project structure and execute it painstakingly together with my reliable friend Google. That said, learning never ends, even the seasoned coding experts can affirm that statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  The journey so far
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--us-tDhb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ArpS_faDkOBmTLOac" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--us-tDhb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ArpS_faDkOBmTLOac" alt="_Photo by Clay Banks on Unsplash_" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started as any other coding newbie would by writing a ‘Hello World’ statement from the introductory lessons of W3Schools. Having studied an array of programming languages, I could see how Python’s syntax was more beginner-friendly. I was able to brush through the fundamentals, but a sudden shift came in when I was scrolling through Twitter one day. I was met with a BootCamp announcement tweet from Data Science East Africa and Lux Academy, offering a free three week Python mentorship program. I felt like it was a calling since I was on this journey of learning Python. The three weeks are over now as I’m posting this and this was an experience that made me change my approach to mastering Python, the right way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mastering Python, the right way
&lt;/h2&gt;

&lt;p&gt;This is no huge secret to anyone willing to improve their coding skills, whether it is in programming or even other career fields. Project-based learning is the answer. I cannot emphasize enough how this has been beneficial to me and to everyone who attended the program.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ES3Ct2WF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AwrvtxRNdOY1AGDRi" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ES3Ct2WF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AwrvtxRNdOY1AGDRi" alt="_Photo by Markus Winkler on Unsplash_" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am a testament to different learning approaches, and I can say that project-based learning has been able to cut my study time significantly. I was anticipating it to take at least some months to get done with the Python fundamentals but at the moment, I have worked on some projects and articles in the three weeks, something I wouldn’t even dream of achieving.&lt;/p&gt;

&lt;h2&gt;
  
  
  Executing the plan
&lt;/h2&gt;

&lt;p&gt;Project-based learning is a learning method whereby you get to gain knowledge while solving a real-life problem. This is literally killing two birds with one stone. At the end of it, you will have the experience and a project to back it.&lt;/p&gt;

&lt;p&gt;The Python community is a great place to be if you are willing to go through this route. You can always start by getting an outline of the various fundamental topics required to be skilled in the language. This will help you tick every topic you learn while undertaking the projects. There are those base units of a language like variables, comments and data types that would take a short time to be familiar with. Now you are ready to execute basic projects as you level up. You can begin by searching for a simple project built using Python, after that, work on a similar idea and then move to the next level, from there it is just a rinse and repeat process. You can also fine-tune your search to suit your learning requirements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2DApEUM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/807/1%2AOH-owJAYVH7FSjrRM3ijTQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2DApEUM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/807/1%2AOH-owJAYVH7FSjrRM3ijTQ.png" alt="_Video results from YouTube search_" width="807" height="549"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don’t forget to always comment on your code. It will help everybody who will be interacting with your code, including yourself. Also, a well organized and structured code is one of the best practices to have in mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus points
&lt;/h2&gt;

&lt;p&gt;If you were keen enough, you would have seen that I talked about article writing. Yes, this has been one of my favourite hobbies recently. Another thing that has helped me in my learning journey is the push from peer learning communities. I am not that great at writing articles but through the guidance of the Lux Academy community, I have been able to share my knowledge online in the hope of helping someone out there.&lt;/p&gt;

&lt;p&gt;Drawing from that, it is wise for one to be active in the coding community and always strive to give back and you’ll get more. The coding community is one of the warm-hearted groups and there isn’t ridicule, discrimination or stereotypes. I wish you well in your coding journey.&lt;/p&gt;

</description>
      <category>learningtocode</category>
      <category>python</category>
      <category>coding</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms With Python</title>
      <dc:creator>Flavian Kyande</dc:creator>
      <pubDate>Mon, 21 Feb 2022 16:09:44 +0000</pubDate>
      <link>https://dev.to/flaviankyande/introduction-to-data-structures-and-algorithms-with-python-347n</link>
      <guid>https://dev.to/flaviankyande/introduction-to-data-structures-and-algorithms-with-python-347n</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d3si6oh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AwcYjK0xTE4vjGjgAYuiRxQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d3si6oh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AwcYjK0xTE4vjGjgAYuiRxQ.jpeg" alt="_Photo by Shubham Dhage on Unsplash_" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A data structure is a physical representation of how data is organized and manipulated. Data Structures are defined by how they can store and organize single data elements and the algorithms available for accessing and manipulating the data.&lt;/p&gt;

&lt;p&gt;This article will cover the data structure part of Data Structures and Algorithms, also succeeding the previous Introduction to Python article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@flaviankyande/python-101-introduction-to-modern-python-971d4164302"&gt;Python 101: Introduction to Modern Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python has two types of data structures namely:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built-In data structures,&lt;/strong&gt; that are already defined within the Python language. Examples include lists, tuples, sets, dictionaries and&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User-defined data structures&lt;/strong&gt; give a user the power to define and control their functionality. Examples include stack, queues, trees, linked lists, graphs and hash maps.&lt;/p&gt;

&lt;p&gt;We will look at some data structures used in Python, which are lists, tuples, sets, dictionaries, linked lists, stack and queues&lt;/p&gt;

&lt;h2&gt;
  
  
  Lists
&lt;/h2&gt;

&lt;p&gt;Lists are built-in mutable(can be changed) data structures used to store multiple items in a single variable. Lists are created using the square brackets and each item in the list is enclosed in quotes and separated by a comma. They can also be created using the list() constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# declaring a list with different data types
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# declaring a list with the constructor method, taking note of double parenthesis
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists store multiple types of data and duplicates. Lists are also ordered thus making it easy for each item to be accessed using indexes, where the first item index is 0 and the last item index is n-1 where n is the number of items in the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tuples
&lt;/h2&gt;

&lt;p&gt;Tuples, just like lists, store multiple items in a variable. The only difference is that tuples are immutable(they can not be changed), and they are created by enclosing the items using parenthesis. Tuples can also be declared using the tuple() constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# declaring a tuple with different data types
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# declaring a tuple with the constructor method, taking note of double parenthesis
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sets
&lt;/h2&gt;

&lt;p&gt;Sets can be differentiated from tuples in the way that they do not have indexes hence are unindexed and unordered. They are also unchangeable once created but one can add or remove items from the set. Sets do not allow duplicate items, therefore, duplicate items in a set are ignored. Sets are declared by wrapping items in curly brackets or using the set() constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# declaring a tuple with different data types
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# declaring a tuple with the constructor method, taking note of double parenthesis
&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;'earth'&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;our&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;world&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dictionaries
&lt;/h2&gt;

&lt;p&gt;A dictionary in Python stores data in key: value pair format. The keys are used as a reference to the value paired with. Dictionaries are ordered, mutable and do not allow duplicate items keys. This is an example of a dictionary that stores each of the planet’s radius sizes in kilometres.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;planet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dictionary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;'Mercury'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Venus'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6052&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Mars'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3390&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Jupiter'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;69911&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Saturn'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;58232&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Uranus'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25362&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'Neptune'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24622&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Linked Lists
&lt;/h2&gt;

&lt;p&gt;Imagine that you had a Python program containing a list of an unknown number of participants in a Kaggle competition that would update every time an entry would be received. The ordinary Python list would push all the other participants below the rank of a new entry by allocating new memory space and copying the values on their required positions. This would mean more delay in our program contrary to what we want.&lt;/p&gt;

&lt;p&gt;Luckily, linked lists solve that issue. Linked lists contain several lists linked by nodes and pointers that have a reference value for each of the linked lists making it easy to introduce new data values. This method saves the program the hustle of allocating and copying data into new memory spaces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UyAEHG47--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Au3es0khVnaGhQeR6ftMhDA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UyAEHG47--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Au3es0khVnaGhQeR6ftMhDA.png" alt="linked lists" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack
&lt;/h2&gt;

&lt;p&gt;Stack is a linear data structure that utilizes the Last In First Out(LIFO) sequence. A perfect example is when you open your browser history, the sites you visited are stacked in descending order such that the recently visited sites appear at the top of the history data.&lt;/p&gt;

&lt;p&gt;In Python, a stack is achieved through the “.append()” and “.pop()” methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# creating an empty list
&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Jupiter'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Venus'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# print the list
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# remove the first item in the list
&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# print the final list
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final output will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Jupiter'&lt;/span&gt;, &lt;span class="s1"&gt;'Earth'&lt;/span&gt;, &lt;span class="s1"&gt;'Venus'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Jupiter'&lt;/span&gt;, &lt;span class="s1"&gt;'Earth'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This signifies that Venus has been removed first, which was the last item we entered in the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Queues
&lt;/h2&gt;

&lt;p&gt;Queues work opposite to stacks in that they process data in the First In First Out Sequence(FIFO). All the requests are handled in the order in which they were received.&lt;/p&gt;

&lt;p&gt;In Python, queues are made by using the “.insert(0, item)” method, the code would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# creating an empty list
&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# adding member items to the list
&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Jupiter'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Venus'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# printing the list
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;planets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Venus'&lt;/span&gt;, &lt;span class="s1"&gt;'Earth'&lt;/span&gt;, &lt;span class="s1"&gt;'Jupiter'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we want to remove the items using the “.pop()” method, the first item which was entered, Jupiter, will be the first item out of the list&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>Python 101: Introduction to Modern Python</title>
      <dc:creator>Flavian Kyande</dc:creator>
      <pubDate>Mon, 14 Feb 2022 17:17:41 +0000</pubDate>
      <link>https://dev.to/flaviankyande/python-101-introduction-to-modern-python-34df</link>
      <guid>https://dev.to/flaviankyande/python-101-introduction-to-modern-python-34df</guid>
      <description>&lt;h2&gt;
  
  
  Brief Python Introduction
&lt;/h2&gt;

&lt;p&gt;I have been lucky to jump into the Python bandwagon this year and I can feel the enthusiasm and support the Python community has had to offer to learners like me. Having gone through the basics, here is what I could gather from learning Python that may help anyone willing to start their Python journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Python_(programming_language)"&gt;Python&lt;/a&gt;&lt;/strong&gt; was released back in 1991 by &lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Guido_van_Rossum"&gt;Guido van Rossum&lt;/a&gt;&lt;/strong&gt; with the intention of being as powerful as the other major languages, having an easy syntax thus making it understandable as plain English and open source. It is fair to say that it achieved its objectives and now it is one of if not the most popular programming language.&lt;br&gt;
Python is easy to install, set up and begin to code with. Python is used extensively in data science, web development, games, pc apps, business systems and many more areas in the technology industry.&lt;/p&gt;


&lt;h2&gt;
  
  
  Installing Python
&lt;/h2&gt;

&lt;p&gt;Python has multiple ways for you to install on your machine. It depends on what is suitable for you and also, your computer specifications play a big part. It is always better to research the specifications required before installing.&lt;br&gt;
It also depends on your career path. If you are in the data science field like me, &lt;strong&gt;&lt;a href="https://www.anaconda.com/products/individual"&gt;Anaconda&lt;/a&gt;&lt;/strong&gt; would be a suitable option for you. This means there is no one fits all approach in installing python, that option solely lies on you. You can also check the official Python website for specific download versions, for &lt;strong&gt;&lt;a href="https://docs.python.org/3/using/windows.html"&gt;Windows&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="https://docs.python.org/3/using/mac.html"&gt;Mac&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://docs.python.org/3/using/unix.html"&gt;Linux&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Getting Started with Python
&lt;/h2&gt;

&lt;p&gt;In this article, we will be using the planets to go through the basic concepts of Python. We will start with the commonly used code line all over, greeting our planet Earth using the print function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Hello World!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running this code, the output will be ‘Hello World!’. Congratulations! You have successfully run your Python code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Comments
&lt;/h2&gt;

&lt;p&gt;Comments are vital to coding. They help the user to understand their code better which can be advantageous in your learning process. Commenting also helps other developers read your code with ease. When you comment on your code it is a win-win situation for everyone who will interact with your code which you’ll notice going through this article.&lt;br&gt;
In Python, the comments are made using the hashtag or pound sign (#) before the comment line. You can also you the keyboard shortcut &lt;code&gt;ctrl + /&lt;/code&gt; to comment. We will start by commenting on our previous print statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# printing a planet greeting message
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Hello World'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when anyone revisits your code including you, they will have a gist of your code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;Variables are the basic unit of a programming language. These are used as a reference to an object. They store values assigned to them for use in the program. Variables take the last value assigned, so it is wise to use different variable names for different values in your code.&lt;br&gt;
The following convention is used in the Python variable naming:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H57J9RMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AdKMkqOxRxEraIMBj8usWfA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H57J9RMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AdKMkqOxRxEraIMBj8usWfA.png" alt="Image from Naming Convention" title="Image from Naming Convention" width="785" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can assign values to variables in Python without declaration. Continuing with our planet greeting, we can assign the greeting to a variable as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# assigning a variable to our greeting message
&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Hello World!'&lt;/span&gt;
&lt;span class="c1"&gt;# printing the message variable
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Data Types
&lt;/h2&gt;

&lt;p&gt;A data type is a classification of values that can be stored in a variable. Some of the most used data types in Python are strings, numbers (integers and floats), boolean, lists, tuples, sets and dictionaries.&lt;br&gt;
You can get the data type of a variable by using the &lt;code&gt;type()&lt;/code&gt; function on any object. Let’s apply this in the previous variable we had:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# print the data type of our message variable
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be &lt;code&gt;&amp;lt;class ‘str’&amp;gt;&lt;/code&gt;, signifying that the data belongs to the string type.&lt;br&gt;
We can also create a list for our planets in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;planets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'Mercury'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Venus'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Mars'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Jupiter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Saturn'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Uranus'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Neptune'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are just some of the &lt;strong&gt;&lt;a href="https://docs.python.org/3.10/library/datatypes.html"&gt;data types&lt;/a&gt;&lt;/strong&gt; available in Python.&lt;/p&gt;




&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;Operators are used to telling the program to perform either arithmetic, logical, assignment or comparison operations on variables and values.&lt;br&gt;
We’ve already used an assignment operator above to assign values to variables with the equal sign (=).&lt;br&gt;
&lt;strong&gt;&lt;a href="https://www.w3schools.com/python/python_operators.asp"&gt;W3 Schools&lt;/a&gt;&lt;/strong&gt; explains these operators with some code examples.&lt;br&gt;
We can check if our planet Earth is in the planets list we created above through the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# operator to check if Earth is in the planets list
&lt;/span&gt;&lt;span class="s"&gt;'Earth'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;planets&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print True since as the Membership operator &lt;code&gt;in&lt;/code&gt; explains, it returns True if a value is contained in a set of values.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conditionals
&lt;/h2&gt;

&lt;p&gt;This is a powerful tool in programming that places two or more variables against each other under set conditions to returning either true or false. Conditionals work hand in hand with most of the operators above to return a value that meets the conditions stated in a program.&lt;br&gt;
In our planets data, we can create a &lt;strong&gt;&lt;a href="https://www.w3schools.com/python/python_dictionaries.asp"&gt;dictionary&lt;/a&gt;&lt;/strong&gt; in Python to store each planet’s size and print the planets larger than Earth by using conditions in the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# a dictionary that has planets and their radius size in km
&lt;/span&gt;&lt;span class="n"&gt;planet_dictionary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;'Mercury'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Venus'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6052&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6371&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Mars'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3390&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Jupiter'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;69911&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Saturn'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;58232&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Uranus'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25362&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'Neptune'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24622&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# condition for looping through the dictionary values and printing planets larger than earth
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;planet_dictionary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;planet_dictionary&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;planet_dictionary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Earth'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print out Jupiter, Saturn, Uranus and Neptune since they are larger than Earth.&lt;/p&gt;




&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;A function is a block of reusable code that is used to perform a single task. There are two types of functions in Python, built-in and user-defined functions&lt;br&gt;
Built-in functions come in predefined in the program. We have been using &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;type()&lt;/code&gt;, which come with the Python program, that helps us perform useful actions.&lt;br&gt;
User-defined functions are functions created by the user to help in achieving specific tasks. In Python, user-defined functions begin with the word def.&lt;br&gt;
We will create a function that can be used to perform the task above so that we wouldn’t have to type it again when we need to reuse it for other objects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# function that outputs planets larger than than user's planet
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;larger_than_planet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
      &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Looking for planets larger than Neptune
&lt;/span&gt;&lt;span class="n"&gt;larger_than_planet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Neptune'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;planet_dictionary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above will return Jupiter, Saturn and Uranus. This is our own user-defined function that enables us to input our planet of choice and returns planets larger than our choice.&lt;/p&gt;




&lt;h2&gt;
  
  
  Classes
&lt;/h2&gt;

&lt;p&gt;Class is a model of an object that defines or specifies all the properties of objects. Here we have two terms, object and class, which we have to break down.&lt;br&gt;
Going back to our planets example, we can say that the planet is our model or blueprint. It helps us define the properties (size, distance from sun) that we require in each of the planets (object).&lt;br&gt;
In Python code, this would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# creating a Planets class
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Planets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# adding atttributes to our class
&lt;/span&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist_from_sun&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;planet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;planet&lt;/span&gt;
    &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;
    &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dist_from_sun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dist_from_sun&lt;/span&gt;
&lt;span class="c1"&gt;# adding a planet instance to our class
&lt;/span&gt;&lt;span class="n"&gt;first_planet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Planet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Mercury'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2240&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;58&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# printing the size of the first planet
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first_planet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The size of Mercury which is 2240, will be printed. You can learn more about classes on the &lt;strong&gt;&lt;a href="https://www.w3schools.com/python/python_classes.asp"&gt;W3 Schools website&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
