<?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>Forem: Rono Collins</title>
    <description>The latest articles on Forem by Rono Collins (@collins42rono).</description>
    <link>https://forem.com/collins42rono</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%2F816164%2F23a1196f-81f1-44f5-b5ab-730b17be8918.jpg</url>
      <title>Forem: Rono Collins</title>
      <link>https://forem.com/collins42rono</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/collins42rono"/>
    <language>en</language>
    <item>
      <title>An introduction to Laravel: The PHP framework for modern web development</title>
      <dc:creator>Rono Collins</dc:creator>
      <pubDate>Wed, 06 Sep 2023 06:21:48 +0000</pubDate>
      <link>https://forem.com/collins42rono/an-introduction-to-laravel-the-php-framework-for-modern-web-development-o0o</link>
      <guid>https://forem.com/collins42rono/an-introduction-to-laravel-the-php-framework-for-modern-web-development-o0o</guid>
      <description>&lt;p&gt;Laravel is a PHP web application framework and it has emerged as a game-changer in the world of web development. Since its release in 2011 by Taylor Otwell, it has gained immense popularity among developers due to its elegant syntax, robust features, and a thriving community. This is an introductory blog post to explore what makes Laravel a top choice for modern web development and why you should use it for your next big project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Laravel?
&lt;/h2&gt;

&lt;p&gt;Laravel was created with a focus on simplicity, readability, and ease of use. It's designed to help developers build scalable and maintainable web applications with less effort. Here are some compelling reasons why Laravel stands out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Elegant Syntax: Laravel's syntax is clean, expressive, and enjoyable to work with. It simplifies common tasks and reduces boilerplate code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modularity: The framework is built on a modular structure, allowing developers to use components like authentication, routing, and caching independently, giving them more flexibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Blade Templating: Laravel's Blade templating engine provides an intuitive and powerful way to create dynamic views with reusable templates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Database Query Builder: Laravel's database query builder and ORM (Eloquent) make it easy to work with databases, simplifying tasks like database migrations and querying.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Artisan CLI: Laravel comes with a command-line tool called Artisan, which automates repetitive tasks and allows developers to create custom commands effortlessly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strong Community: Laravel boasts a large and active community of developers who contribute to packages, tutorials, and extensions. This community support is invaluable for learning and troubleshooting.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Features of Laravel
&lt;/h2&gt;

&lt;p&gt;Laravel is packed with a ton of features that will make your web development journey a bliss ✨👌&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Authentication and Authorization: Laravel simplifies user authentication and authorization, making it easy to protect routes and control access to your application. With amazing starter kit packages like &lt;a href="https://laravel.com/docs/10.x/starter-kits" rel="noopener noreferrer"&gt;Laravel Breeze&lt;/a&gt;  you can add authentication easily in your application by scaffolding it with the routes, controllers, and views you need to register and authenticate your application's users. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Routing: Defining routes in Laravel is straightforward, thanks to the expressive routing system.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use Illuminate\Support\Facades\Route;

Route::get('/greeting', function () {
    return 'Hello World';
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Middleware: Middleware allows you to filter HTTP requests entering your application. It's great for tasks like authentication, logging, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Eloquent ORM: Eloquent, Laravel's ORM, provides an intuitive way to interact with databases. It offers relationships, eager loading, and model factories.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:model Flight -m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command creates a model and a migration for the database you can edit to suit your ideal model and database structure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Database Migrations: Laravel's migration system enables version control for your database schema, making it easy to work collaboratively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Testing: Laravel has excellent support for testing, with &lt;a href="https://phpunit.de/" rel="noopener noreferrer"&gt;PHPUnit&lt;/a&gt; integration and a convenient testing environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Task Scheduling: Schedule tasks like sending emails and generating reports with Laravel's elegant task scheduler.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    protected function schedule(Schedule $schedule): void
    {
        $schedule-&amp;gt;call(function () {
            DB::table('recent_users')-&amp;gt;delete();
        })-&amp;gt;daily();
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;To start using Laravel, you'll need PHP🐘, &lt;a href="https://getcomposer.org/download/" rel="noopener noreferrer"&gt;Composer&lt;/a&gt; (a PHP package manager), and a web server (e.g., &lt;a href="https://httpd.apache.org/download.cgi" rel="noopener noreferrer"&gt;Apache&lt;/a&gt;or &lt;a href="https://www.nginx.com/" rel="noopener noreferrer"&gt;Nginx&lt;/a&gt;) installed on your machine. If you're using windows, you can set up &lt;a href="https://www.apachefriends.org/download.html" rel="noopener noreferrer"&gt;xampp&lt;/a&gt; to have PHP and MySQL server installed in your machine. You can then create a new Laravel project using Composer with a simple command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer create-project laravel/laravel my-laravel-app

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can do the same by installing laravel installer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer global require "laravel/installer"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thereafter, you can create a new project using command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel new example-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new Laravel project named example-app with the initial laravel files&lt;/p&gt;

&lt;p&gt;You can then navigate to the project folder then run the Laravel project from the command line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd example-app

php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then access the project from your browser by accessing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8080/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is it! Your new laravel application.&lt;/p&gt;

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

&lt;p&gt;Laravel has revolutionized PHP web development by providing developers with a powerful and elegant framework for building modern web applications. Its simplicity, robust features, and active community support make it a top choice for web developers worldwide. Whether you're a seasoned developer or just getting started, Laravel is worth exploring as your go-to framework for crafting web applications that stand out in the digital landscape.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>php</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Python for everyone: Mastering Python The Right Way</title>
      <dc:creator>Rono Collins</dc:creator>
      <pubDate>Tue, 01 Mar 2022 08:01:30 +0000</pubDate>
      <link>https://forem.com/collins42rono/python-for-everyone-mastering-python-the-right-way-5d5p</link>
      <guid>https://forem.com/collins42rono/python-for-everyone-mastering-python-the-right-way-5d5p</guid>
      <description>&lt;p&gt;Mastering any programming languages requires one to learn a ton of skills. It is not only about coding in the language but also learning various concepts which may come handy in different problem solving scenarios. You can learn more about python using it's &lt;a href="https://docs.python.org/3/tutorial/" rel="noopener noreferrer"&gt;Python Documentation and Tutorial&lt;/a&gt;. Throughout this write up we'll be looking at the various concepts one should learn while mastering Python the right way.&lt;/p&gt;

&lt;p&gt;These Python concepts will go from beginner to advanced concepts. To master them needs practice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Variables are containers for storing data or values:&lt;br&gt;
&lt;code&gt;a = 5&lt;/code&gt;&lt;br&gt;
You can get the datatype of variable using &lt;code&gt;type()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type(a)
&amp;lt;class 'int'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Naming variables becomes a major concern when working with large programs and you need descriptive names to have readable code.&lt;br&gt;
A variable like &lt;code&gt;a&lt;/code&gt; may be hard to understand it's function later when you are reviewing the code or when code is handed over. A variable like &lt;code&gt;idNumber&lt;/code&gt; may be easy to understand.&lt;/p&gt;

&lt;p&gt;Here are a few additional rules to remember when working with Python variable names:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Should start with a letter &lt;code&gt;a-z&lt;/code&gt; or the underscore character &lt;code&gt;_&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Should not begin with a numerical value &lt;code&gt;0-9&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Variable names are case-sensitive (book, Book and BOOK are considered as three different variables) &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conditions&lt;/strong&gt;&lt;br&gt;
Python supports the use of the following logical conditions :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Equals:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Checks if two values are equal and output &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Not Equal:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a != b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks if two values are not equal and print &lt;code&gt;True&lt;/code&gt;, otherwise outputs &lt;code&gt;False&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Less than:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; a &amp;lt; b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks if the first value a is less than b&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Less than or equal to:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a &amp;lt;= b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks if value a is less or equal to b&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Greater than:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a &amp;gt; b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks if value a is greater than b. If true it outputs &lt;code&gt;True&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chained Conditionals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python allows for nested selections of conditions which is referred to as chained conditionals&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if a &amp;lt; b:
    print("a is less than b")
elif a &amp;gt; b:
    print("a is larger than b")
else:
    print("a and b are equal")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The conditions are nested using if, elif &lt;code&gt;else if&lt;/code&gt; and else to check if all conditions are met&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operators are used to perform operations in values and variables. Here is a list of operators:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic operators:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;addition&lt;/code&gt;,- &lt;code&gt;subtraction&lt;/code&gt;,  / &lt;code&gt;division&lt;/code&gt;, % &lt;code&gt;modulus&lt;/code&gt;, * &lt;code&gt;multiplication&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Assignment operators:&lt;/strong&gt; =, +=, -=, *=, /=.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comparison operators:&lt;/strong&gt;   &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-  ==   Equal   a == b  
-  !=   Not equal   a != b  
-  &amp;gt;    Greater than    a &amp;gt; b   
-  &amp;lt;    Less than   b &amp;lt; a   
-  &amp;gt;=   Greater than or equal to  &amp;gt;= b  
-  &amp;lt;=   Less than or equal to  b &amp;lt;= a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Identity operators:&lt;/strong&gt;&lt;br&gt;
Used to compare objects, not in terms of equality but if they refer to the same object&lt;br&gt;
&lt;code&gt;a is b&lt;/code&gt;, &lt;code&gt;a is not b&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and, or, not. &lt;code&gt;and&lt;/code&gt; between two conditions e.g if a=10 and a&amp;gt;9 means both conditions must be met in order to continue. &lt;code&gt;Or&lt;/code&gt; chooses if either one of the conditions are met to allow continuation of the program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Control Flow (If/Else)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Control flow determines the order in which a program code &lt;br&gt;
 executes. The control flow of a program is regulated by conditional statements, loops, and function calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;if else statements&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if condition/expression:
    statement to be executed
elif condition/expression:
    statement to be executed
elif condition/expression:
    statement to be executed
else:
    statement to be executed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if a &amp;lt; 0:
    print "a is negative"
elif b % 2:
    print "b is positive and odd"
else:
    print "b is even and non-negative"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Loops and Iterables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Looping in Python is handled by for, while, if loops.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;for loop&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in something_iterable:
    print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;while loop&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count = 0
while (count &amp;lt; 3):
    count = count + 1
    print("Count me")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;if-else loop&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition):
    statements
else:
    statements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An iterable is anything you can loop over using a for loop in python. Sequences such as lists, tuples, and strings are iterable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in something_iterable:
    print(i)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basic Data Structures&lt;/strong&gt;&lt;br&gt;
Data structures define how data is stored and operations to be performed on them. To build great programs, you first need to understand what data structures and algorithms may work on them. &lt;br&gt;
Have a look at &lt;a href="https://dev.to/collins42rono/introduction-to-data-structures-and-algorithms-with-python-1k0h"&gt;An introduction to data structures and algorithms in Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Functions are a fundamental to programming. Functions allow us to write blocks of called which only executes when the function is called. To write a function in python the &lt;code&gt;def&lt;/code&gt; keyword is used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myFunction():
  print("Hello there")

myFunction()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may also take arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myOtherFunction(str):
   print(str)

myOtherFunction("Hello")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  More topics to learn as you master Python
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mutable vs Immutable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mutable refers data types whose values can be modified e.g list, dictionary, and sets while immutable are data types whose values cannot be changed once they are described e.g int, float, decimal, bool, string, tuple, and range.&lt;br&gt;
&lt;strong&gt;File Input and Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Involves operations of files necessary for data operations. Some operations are:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Opening a file.
2. Reading from the file.
3. Writing data to file.
4. Closing a file after operations of read or write.
5. Creating and deleting a file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Receiving input from user using input() function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = input("Enter your name: ")
print (f'You entered {name}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter your name:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening files;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f = open('workfile.txt', 'w')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code example opens up a file named &lt;code&gt;workfile.txt&lt;/code&gt; if it is in your working directory and the &lt;code&gt;w&lt;/code&gt; means it will be opened in a mode for &lt;code&gt;writing&lt;/code&gt;. To read the mode &lt;code&gt;r&lt;/code&gt; for read is used.&lt;/p&gt;

&lt;p&gt;To go ahead and read content in the workfile.txt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;content = f.read()
print(content)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And make sure to close the file after operations;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Object Oriented Programming (OOP)&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Start by looking at my &lt;a href="https://dev.to/collins42rono/object-oriented-programming-with-python-2c35"&gt;introduction to object oriented programming in python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Structures and algorithms&lt;/strong&gt; from &lt;a href="https://dev.to/collins42rono/introduction-to-data-structures-and-algorithms-with-python-1k0h"&gt;introduction to data structures and algorithms with python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comprehensions&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Comprehensions allow us to create new sequence using another sequence;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aList = [i for i in range(5)]
print(aList)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Lambda Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lambda functions in python are normal functions but they do not have a name and have only one line of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambda x: x+x

x is the argument in the above function


(lambda x: x*2)(12)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The argument x is set to 12 outside the function and answer output is 24&lt;/p&gt;

&lt;p&gt;This tutorial is a sequel to &lt;a href="https://dev.to/collins42rono/object-oriented-programming-with-python-2c35"&gt;Object Oriented Programming with Python&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>python</category>
      <category>software</category>
    </item>
    <item>
      <title>Object Oriented Programming with Python</title>
      <dc:creator>Rono Collins</dc:creator>
      <pubDate>Mon, 28 Feb 2022 10:40:30 +0000</pubDate>
      <link>https://forem.com/collins42rono/object-oriented-programming-with-python-2c35</link>
      <guid>https://forem.com/collins42rono/object-oriented-programming-with-python-2c35</guid>
      <description>&lt;p&gt;A look into the Object Oriented concepts using Python after understanding &lt;a href="https://dev.to/collins42rono/introduction-to-data-structures-and-algorithms-with-python-1k0h"&gt;Data Structures and Algorithms with Python&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Programming Paradigms
&lt;/h2&gt;

&lt;p&gt;While writing a program, there are various features a program can contain. These different features are described as programming paradigms. Various programing paradigms are: functional programming, logical programming, imperative programming and then there is object oriented programming.&lt;/p&gt;

&lt;p&gt;Programming languages support most of these paradigms and therefore it depends on the needs of the programmer to choose what works best for the current problem being solved.&lt;/p&gt;

&lt;p&gt;In Object Oriented Programming, attributes of an object are first designed into a class, then an instance of the class which is an object is created. Take for instance a book which will contain name or title of the book, author, and number of pages. They are all attributes of a book which is considered a class. An instance of this book may be "Python101" by "Mike Driscoll" with 100 pages. This is our object since it is an instance of our class book.&lt;/p&gt;

&lt;p&gt;Let's look at another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car():
    def __init__(self, make, model):
        self.make = make
        self.model= model

nissan1 = Car("Nissan", "Altima")
print(nissan1.make)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll dive deeper into the structure of the code but first let's understand it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OUPUT&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nissan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above example represents a class Car which has attributes make and model.&lt;br&gt;
Outside the class we have instantiated an object named &lt;code&gt;nissan1&lt;/code&gt; and gave it make and model &lt;code&gt;Nissan&lt;/code&gt; and &lt;code&gt;Altima&lt;/code&gt;. The &lt;code&gt;print&lt;/code&gt; method outputs the make of the car.&lt;/p&gt;
&lt;h2&gt;
  
  
  Main OOP concepts Python
&lt;/h2&gt;

&lt;p&gt;We have looked at the objects and classes in Python. With a class being more of a blueprint of an object and an object an instance of a class. The class Car in the above example uses a keyword &lt;code&gt;class&lt;/code&gt; and the object &lt;code&gt;nissan1&lt;/code&gt; uses the defined class &lt;code&gt;Car&lt;/code&gt; to create an instance of &lt;code&gt;Car&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also notice the &lt;code&gt;__init__&lt;/code&gt; keyword. This is a constructor similar to the ones in Java and it uses the keyword &lt;code&gt;self&lt;/code&gt; to initialize attributes of our class.&lt;/p&gt;

&lt;p&gt;Object Oriented Programming also allows for other concepts with classes and objects i.e., &lt;code&gt;Inheritance&lt;/code&gt;, &lt;code&gt;Encapsulation&lt;/code&gt;, and &lt;code&gt;Polymorphism&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance&lt;/strong&gt;&lt;br&gt;
Inheritance allows one class &lt;code&gt;child class&lt;/code&gt; to inherit properties of another already defined class &lt;code&gt;parent class&lt;/code&gt;. This enables reusability of code which is already written in one class to be used without redundancy of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# parent class
class Person(object):

    #the constructor
    def __init__(self, name, age):
        self.name = name
        self.age= age

    def display(self):
        print(self.name)
        print(self.age)

    def details(self):
        print("My name is {}".format(self.name))
        print("age: {}".format(self.age))

# child class. Notice the parent class (Person)
class Employee(Person):
    def __init__(self, name, age, salary, post):
        self.salary = salary
        self.post = post

        # invoking the parent class
        Person.__init__(self, name, age)

    def details(self):
        print("My name is {}".format(self.name))
        print("Age: {}".format(self.age))
        print("Post: {}".format(self.post))


# creation of an object variable or an instance
employee1 = Employee('Rahul', 45, 200000, "Intern")

# calling a function of the class Person using
# its instance
employee1.display()
employee1.details()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Polymorphism&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Polymorphism allows an object to take many forms&lt;/p&gt;

&lt;p&gt;In the above example an object person can take the form &lt;code&gt;Person&lt;/code&gt; or &lt;code&gt;Employee&lt;/code&gt; since the child class inherits from the parent class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Book():
    def intro(self):
        print("I have a name")

    def pages(self):
        print("I have a number of pages")

class Novel(Book):
    def pages(self):
        print("Novels too have pages")

class drawingBook(Book):
    def pages(self):
        print("A drawing book must also have pages")

book1 = Book()
novel1 = Novel()
drawbook1 = drawingBook()

novel1.intro()
book1.intro()
drawbook1.intro()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;OUTPUT&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I have a name
I have a name
I have a name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method used by the other books &lt;code&gt;Novel&lt;/code&gt; and &lt;code&gt;drawingBook&lt;/code&gt; come from the parent class &lt;code&gt;Book&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Encapsulation allow restricted access to methods and variables in Python to prevent data from direct modification. This is achieved by using private attributes. In Python, we denote private attributes using underscore as the prefix i.e., single &lt;code&gt;_&lt;/code&gt; or double &lt;code&gt;__&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's have an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Book:

    def __init__(self):
        self.__maxprice = 900

    def sell(self):
        print("Selling Price: {}".format(self.__maxprice))

    def setMaxPrice(self, price):
        self.__maxprice = price

book1= Book()
book1.sell()

# change the price
book1.__maxprice = 1000
book1.sell()

# using setter function
book1.setMaxPrice(1000)
book1.sell()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Selling Price: 900
Selling Price: 900
Selling Price: 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;__maxprice&lt;/code&gt; has been set to a private .&lt;/p&gt;

&lt;p&gt;The code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;book1.__maxprice = 1000
book1.sell()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;attempts to change the &lt;code&gt;maxprice&lt;/code&gt; to 1000 but it doesn't change as seen in the second output because maxprice is set to private.&lt;/p&gt;

&lt;p&gt;The setter function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;book1.setMaxPrice(1000)
book1.sell()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is used to successfully used to change the max price to 1000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Selling Price: 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms With Python</title>
      <dc:creator>Rono Collins</dc:creator>
      <pubDate>Sun, 20 Feb 2022 07:53:19 +0000</pubDate>
      <link>https://forem.com/collins42rono/introduction-to-data-structures-and-algorithms-with-python-1k0h</link>
      <guid>https://forem.com/collins42rono/introduction-to-data-structures-and-algorithms-with-python-1k0h</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89mymmw5xx563rrlge7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89mymmw5xx563rrlge7q.png" alt=" " width="299" height="168"&gt;&lt;/a&gt;  (source images: google)&lt;/p&gt;

&lt;p&gt;This is an introduction to data structures and algorithms in Python a sequel to &lt;a href="https://dev.to/collins42rono/python101-introduction-to-modern-python-31n5"&gt;Introduction to Modern Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Data Structures and algorithms are fundamental for every programmer when starting out learning a new language. &lt;/p&gt;

&lt;p&gt;Data Structures describe how data is arranged to allow operations to be performed on them efficiently. This describes how we organize, process, retrieve and store data. Some of the common data structures are lists, tuples, dictionaries, sets, linked lists, and arrays.&lt;/p&gt;

&lt;p&gt;Algorithms define the set of operations and instructions that enables the processing of data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Data Structures in Python
&lt;/h2&gt;

&lt;p&gt;We are going to look at data structures in Python; lists, dictionaries, tuples, sets, queues, stacked and linked list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Lists&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33q75pas3z6b3vx6250o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33q75pas3z6b3vx6250o.png" alt=" " width="390" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lists define a set of values which are ordered in a sequence of elements enclosed in square brackets, &lt;code&gt;[]&lt;/code&gt;.The elements in a list can be changed otherwise said to be mutable.&lt;/p&gt;

&lt;p&gt;Example list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myList = ["Rono", "Python", "Code"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output these elements by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(myList)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['Rono', 'Python', 'Code']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example list has a set of elements which can be accessed by their position in the list starting from position [0].&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myList[0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'Rono'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists may allow you to duplicate values by adding similar elements on the list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myList = ['Python', 'Java', 'Python', 'JavaScript']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output length of list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(len(myList))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A list can also contain different data types&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myList= ["ABC", 56, False, 78, "female"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A list can also be created using the list() constructor when square brackets are not used&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myList = list(("orange", "banana", "pineapple"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More to learn about lists&lt;br&gt;
&lt;code&gt;Sorting Lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Copy lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Join lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;List methods&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Dictionaries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v2w81r55bknbgdjkmco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v2w81r55bknbgdjkmco.png" alt=" " width="376" height="134"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Dictionaries in Python store data in key: value pairs contained inside curly braces &lt;code&gt;{}&lt;/code&gt;.&lt;br&gt;
Like lists, they are changeable but do not allow duplicates&lt;/p&gt;

&lt;p&gt;example dictionary&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myDict = 
      {"name": Rono', 
       "Age":7, 
       "gender": 'male'
      }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'name': 'Rono', 'Age': 7, 'gender': 'male'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To access an item in a dictionary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myDict['name']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outputs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'Rono'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change value:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;myDict['name'] = "Python"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'name': 'Python', 'Age': 7, 'gender': 'male'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove item using pop():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myDict= {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
myDict.pop("model")
print(myDict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{'brand': 'Ford', 'year': 1964}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Learning more on dictionaries&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Loop dictionaries&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     for x in myDict:
       print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Copy dictionaries&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  anotherDict = myDict.copy()
  print(anotherDict)
  {'brand': 'Ford', 'year': 1964}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Nested dictionaries&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myDict = {"firstPerson":{"name": "Rono", "age":7},
          "secondPerson":
         {"name": "Collins", "age":8}
         }
print(myDict)
{'firstPerson': {'name': 'Rono', 'age': 7}, 'secondPerson': {'name': 'Collins', 'age': 8}}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dictionary above contains two dictionaries within it. The first one has the title &lt;code&gt;firstPerson&lt;/code&gt; and then contains the details of the first person in a dictionary. The second dictionary within our dictionary contains details of the second person &lt;code&gt;secondPerson&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Tuples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvkoowlek5spt8xm3zn5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvkoowlek5spt8xm3zn5.jpeg" alt=" " width="308" height="164"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Tuples are used to store several items in a single variable.&lt;br&gt;
Tuples are unchangeable unlike lists and dictionaries. Meaning once you create a tuple you cannot alter its contents.&lt;br&gt;
They are also indexed from item [0] like in lists. Therefore you can access the tuple elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ('orange', 'banana', 'pineapple')

type(fruits)

&amp;lt;class 'tuple'&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable &lt;code&gt;fruits&lt;/code&gt; creates a tuple containing a list of fruits&lt;br&gt;
&lt;code&gt;type&lt;/code&gt; is an in-built method in python returns the class types of objects. In the above code it outputs the class type of variable fruits as &lt;code&gt;&amp;lt;class 'tuple'&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Length of tuple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(len(fruits))

3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A tuple can contain different data types:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;car1= ("Engine", 444, False, 440, "Toyota")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using tuple() constructor&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits= tuple(("apple", "banana", "cherry"))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sets in Python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9y67fkjrzanjg3n8h5s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9y67fkjrzanjg3n8h5s.png" alt=" " width="263" height="192"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Sets are used to store multiples elements in a single variable within curly braces. They are unordered, unindexed and unchangeable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mySet= {"pineapple", "pawpaw", "apple"}

print(mySet)

{'apple', 'pineapple', 'pawpaw'}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets does not allow duplication of items, therefore does not recognize two similar items&lt;/p&gt;

&lt;p&gt;A set can also contain items of different data types i.e. strings &lt;code&gt;'name'&lt;/code&gt;, integers &lt;code&gt;7&lt;/code&gt;, Boolean &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It is possible to create a set using set() constructor&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xdoknb7yox4vc7l3qtm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xdoknb7yox4vc7l3qtm.png" alt=" " width="371" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Queues in python are linear data structures in which operations are performed in a First In First Out &lt;code&gt;FIFO&lt;/code&gt;. The first element in is the first element out. Just like in a normal customer queue in which the first customer to enter is the first customer to be served.&lt;/p&gt;

&lt;p&gt;Some operations performed on queues are:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Enqueue: Adds an item to the queue. If the queue is full, then it is said to be an Overflow condition – Time Complexity : O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Dequeue: Removes an item from the queue. The items are popped in the same order in which they are pushed. If the queue is empty, then it is said to be an Underflow condition – Time Complexity : O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Front: Get the front item from queue – Time Complexity : O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Rear: Get the last item from queue – Time Complexity : O(1)&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferifykh9cohbgb3v5fyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferifykh9cohbgb3v5fyq.png" alt=" " width="292" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stacks is a linear data structure that stores data in a linear manner and an element is connected to the previous and next element. Elements are accessed in a Last In First Out order. The last element to be added is the first one to be retrieved.&lt;/p&gt;

&lt;p&gt;Operations carried out in stacks are:&lt;br&gt;
&lt;code&gt;empty() – Returns whether the stack is empty – Time Complexity: O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;size() – Returns the size of the stack – Time Complexity: O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;top() – Returns a reference to the topmost element of the stack – Time Complexity: O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;push(a) – Inserts the element ‘a’ at the top of the stack – Time Complexity: O(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pop() – Deletes the topmost element of the stack – Time Complexity: O(1)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Linked lists in Python
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9sf52wgd05370ywdaorr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9sf52wgd05370ywdaorr.png" alt=" " width="491" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Linked list is a sequence of data elements which are connected together in form of nodes. Each data element contain connection to the next data element in form of a pointer.&lt;/p&gt;

&lt;p&gt;There are different ways in which elements are pointed to the next or previous nodes. The firs node is head node and last node in a linked list known as tail node:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Singly linked lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Doubly linked lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Circular linked lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Circular doubly linked lists&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8m64c4iqd9fj8lnnncd4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8m64c4iqd9fj8lnnncd4.PNG" alt=" " width="647" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A singly linked list is a one direction linked list. So, you can only traverse it in one direction say from tail node to head node or head node to tail node.&lt;/p&gt;

&lt;p&gt;A doubly linked list is a bi-directional linked list. You can transverse it in both directions, next and previous. An element has an extra previous pointer.&lt;/p&gt;

&lt;p&gt;A circular linked list is also a unidirectional linked list. However, it has it's last node pointing to head node.&lt;/p&gt;

&lt;p&gt;A circular doubly linked list is a mixture of a doubly linked list and a circular linked list. Like the doubly linked list, it has an extra pointer called the previous pointer, and similar to the circular linked list, its last node points at the head node. This type of linked list is the bi-directional list. So, you can traverse it in both directions.&lt;/p&gt;

&lt;p&gt;This is an introduction to data structures and algorithms in Python a sequel to &lt;a href="https://dev.to/collins42rono/python101-introduction-to-modern-python-31n5"&gt;Introduction to Modern Python&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>newbie</category>
      <category>developer</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python101: Introduction to Modern Python</title>
      <dc:creator>Rono Collins</dc:creator>
      <pubDate>Thu, 17 Feb 2022 11:02:43 +0000</pubDate>
      <link>https://forem.com/collins42rono/python101-introduction-to-modern-python-31n5</link>
      <guid>https://forem.com/collins42rono/python101-introduction-to-modern-python-31n5</guid>
      <description>&lt;p&gt;Python is a commonly used programming language.&lt;/p&gt;

&lt;p&gt;What is a programming language?&lt;/p&gt;

&lt;p&gt;A programming language is a language used to write instructions which a computer can understand and perform operations implied by the program written.&lt;/p&gt;

&lt;p&gt;Python is a high level language which makes it user friendly in developing programs. It's use is not limited to creating certain programs only hence it is a general purpose language. With Python, you can create applications, games, websites, small programs (scripts) which enable automation of everyday tasks like sending WhatsApp messages or emails and even large projects like an e-commerce website. Python has a lot of libraries which enable massive list of functionalities from Data Science, Machine Learning and Software development. &lt;/p&gt;

&lt;p&gt;Arguably, python is the most popular programming language.&lt;/p&gt;

&lt;h2&gt;
  
  
  History of Python
&lt;/h2&gt;

&lt;p&gt;Python was first conceived in the 1980s and it's implementation was started in 1989 by Guido van Rossum at CWI in the Netherlands as a successor to ABC capable of exception handling and interfacing with the Amoeba operating system. Over time, python has grown to a community which contributes to it's development and growth since it is developed under an OSI-approved open source license. This makes Python freely usable and distributable.&lt;/p&gt;

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

&lt;p&gt;To get started with Python, it is not necessary to have prior programming experience since you can learn programming fundamentals with Python.&lt;/p&gt;

&lt;p&gt;Python programs are developed in an Integrated Development Environment (IDE) which is a software for building applications. It integrates several software tools in a single environment. Some of the most common IDEs for Python are; IDLE which comes with an installation of python, Pycharm, Visual Studio Code, Thonny.&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloading Python and Setting up environment
&lt;/h2&gt;

&lt;p&gt;Choose your most preferred Python version depending on your environment here &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;Python&lt;/a&gt; for Windows, Linux/UNIX, macOS operating systems and install.&lt;br&gt;
Make sure python is installed on your computer's environment PATH.&lt;/p&gt;

&lt;p&gt;To check if you have python installed on a Windows PC, search in the start bar for Python or run the following on the Command Line (cmd.exe):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check if you have python installed on a Linux or Mac, then on Linux open the command line or on Mac open the Terminal and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the Python version installed in your machine.&lt;/p&gt;

&lt;p&gt;You can access python shell from your command line by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Windows and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Linux or Mac&lt;/p&gt;

&lt;p&gt;You can then type your first program into the command line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Hello World")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Hello world!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this will run only once and will not be saved for future reference. To run programs that can be re-run, you need to write them inside an IDE and save them.&lt;/p&gt;

&lt;p&gt;Good news is, you are already started with programming in Python, the most in-demand language.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>software</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
