<?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: Bidhampola</title>
    <description>The latest articles on DEV Community by Bidhampola (@bidhampola).</description>
    <link>https://dev.to/bidhampola</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%2F670263%2F1d19cc9f-aa4d-4f84-802a-0a01a9b494a2.png</url>
      <title>DEV Community: Bidhampola</title>
      <link>https://dev.to/bidhampola</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bidhampola"/>
    <language>en</language>
    <item>
      <title>Getting started with flask</title>
      <dc:creator>Bidhampola</dc:creator>
      <pubDate>Wed, 11 Aug 2021 17:02:25 +0000</pubDate>
      <link>https://dev.to/bidhampola/getting-started-with-flask-3hpe</link>
      <guid>https://dev.to/bidhampola/getting-started-with-flask-3hpe</guid>
      <description>&lt;h2&gt;
  
  
  What I have learnt and gained since day one;
&lt;/h2&gt;

&lt;p&gt;Let me begin by thanking Lux-academy for this great opportunity that was given to me and to us as a whole.&lt;br&gt;
Sincerely speaking this bootcamp has further enlightened me about the real world. And it has really made theory at university practical. Thanks to LuX-academy and in particular thanks to the Instructor-Haruna for the tireless effort given in!&lt;/p&gt;
&lt;h3&gt;
  
  
  What I have learnt.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Python basics&lt;/li&gt;
&lt;li&gt;Use of GitHub&lt;/li&gt;
&lt;li&gt;A clue on the data-types and algorithms&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Python basics:
&lt;/h3&gt;

&lt;p&gt;Under this I have learn a lot of things which among others include the following;&lt;br&gt;
Exactly what python is, lists, tuples, dictionaries, sets and extra.&lt;/p&gt;
&lt;h3&gt;
  
  
  Use of GitHub.
&lt;/h3&gt;

&lt;p&gt;I have atleast known how to have my work on GitHub from my local machine. I have also got used to use of commands which looked hard and complicated before joining the bootcamp! Lux-academy thanks!&lt;/p&gt;
&lt;h1&gt;
  
  
  Getting started with flask.
&lt;/h1&gt;

&lt;p&gt;Flask is a web framework that provides libraries to build lightweight web applications in python. It is developed by Armin Ronacher who leads an international group of python enthusiasts (POCCO).&lt;/p&gt;

&lt;p&gt;Flask is a web framework that provides libraries to build lightweight web applications in python. It is developed by Armin Ronacher who leads an international group of python enthusiasts (POCCO). It is based on WSGI toolkit and jinja2 template engine. Flask is considered as a micro framework.&lt;/p&gt;
&lt;h2&gt;
  
  
  How about WSGI and Jinja2 template??
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is WSGI?
&lt;/h3&gt;

&lt;p&gt;It is an acronym for web server gateway interface which is a standard for python web application development. It is considered as the specification for the universal interface between the web server and web application.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is Jinja2?
&lt;/h3&gt;

&lt;p&gt;Jinja2 is a web template engine which combines a template with a certain data source to render the dynamic web pages.&lt;/p&gt;
&lt;h2&gt;
  
  
  Flask Environment Setup
&lt;/h2&gt;

&lt;p&gt;To install flask on the system, we need to have python 2.7 or higher installed on our system. However, we suggest using python 3 for the development in the flask.&lt;/p&gt;
&lt;h3&gt;
  
  
  Install virtual environment (virtualenv)
&lt;/h3&gt;

&lt;p&gt;virtualenv is considered as the virtual python environment builder which is used to create the multiple python virtual environment side by side. It can be installed by using the following command.&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="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>introduction to python functions</title>
      <dc:creator>Bidhampola</dc:creator>
      <pubDate>Sat, 31 Jul 2021 04:22:12 +0000</pubDate>
      <link>https://dev.to/bidhampola/introduction-to-python-functions-g8m</link>
      <guid>https://dev.to/bidhampola/introduction-to-python-functions-g8m</guid>
      <description>&lt;h1&gt;
  
  
  Python functions
&lt;/h1&gt;

&lt;p&gt;A function is a block of code which only runs when it is called.&lt;br&gt;
You can pass data, known as parameters, into a function.&lt;br&gt;
A function can return data as a result.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a Function
&lt;/h2&gt;

&lt;p&gt;In Python a function is defined using the def keyword:&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&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="s"&gt;"Enjoy functions"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;

&lt;h2&gt;
  
  
  Arguments
&lt;/h2&gt;

&lt;p&gt;Information can be passed into functions as arguments.&lt;br&gt;
Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.&lt;br&gt;
The following example has a function with one argument (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fname&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;fname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" Refsnes"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Brian"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Junior"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Lin"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  How is a parameter different from an argument?
&lt;/h2&gt;

&lt;p&gt;A parameter is the variable listed inside the parentheses in the function definition.&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;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fname&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;fname&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;represents&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An argument is the value that is sent to the function when it is called.&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;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Brian"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;Brian&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;represents&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;argument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is it ok now! 😂 If not feel free to learn More on parameter and argument &lt;a href="https://stackoverflow.com/questions/1788923/parameter-vs-argument"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Number of Arguments
&lt;/h2&gt;

&lt;p&gt;By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;This function expects 2 arguments, and gets 2 arguments:&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;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lname&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;fname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Brian"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"lux"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: If you try to call the function with 1 or 3 arguments, you will get an error:&lt;/p&gt;

&lt;h2&gt;
  
  
  Arbitrary Arguments, *args
&lt;/h2&gt;

&lt;p&gt;If you do not know how many arguments that will be passed into your function, add a * before the parameter name in the function definition.&lt;br&gt;
This way the function will receive a tuple of arguments, and can access the items accordingly:&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;If the number of arguments is unknown, add a * before the parameter name:&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;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;kids&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="s"&gt;"The youngest child is "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;kids&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Andy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Lin"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Default Parameter Value
&lt;/h2&gt;

&lt;p&gt;The following example shows how to use a default parameter value.&lt;br&gt;
If we call the function without argument, it uses the default value:&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Norway"&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="s"&gt;"I am from "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Sweden"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"India"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Brazil"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Passing a List as an Argument
&lt;/h2&gt;

&lt;p&gt;You can send any data types of argument to a function (string, number, list, dictionary etc.), and it will be treated as the same data type inside the function.&lt;br&gt;
E.g. if you send a List as an argument, it will still be a List when it reaches the function:&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&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;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food&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;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"apple"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"banana"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"cherry"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Return Values
&lt;/h2&gt;

&lt;p&gt;To let a function return a value, use the return statement:&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;x&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;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&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;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&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;my_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The pass Statement
&lt;/h2&gt;

&lt;p&gt;function definitions cannot be empty, but if you for some reason have a function definition with no content, put in the pass statement to avoid getting an error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;myfunction&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Recursion
&lt;/h2&gt;

&lt;p&gt;Python also accepts function recursion, which means a defined function can call itself.&lt;br&gt;
Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result.&lt;br&gt;
The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically-elegant approach to programming.&lt;br&gt;
In this example, tri_recursion() is a function that we have defined to call itself ("recurse"). We use the k variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0).&lt;br&gt;
To a new developer it can take some time to work out how exactly this works, best way to find out is by testing and modifying it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recursion Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tri_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
     &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tri_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&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;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&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;"&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s"&gt;Recursion Example Results"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tri_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>python basics</title>
      <dc:creator>Bidhampola</dc:creator>
      <pubDate>Sat, 24 Jul 2021 14:55:04 +0000</pubDate>
      <link>https://dev.to/bidhampola/python-basics-155</link>
      <guid>https://dev.to/bidhampola/python-basics-155</guid>
      <description>&lt;p&gt;Python basics is just an introduction to the over view of python as a programming language that every programmer should know in order to work well with python.&lt;br&gt;
Python is an interpreted language, meaning the code is executed as soon as its written.&lt;br&gt;
Just like other languages have extensions, python’s extension is .py&lt;/p&gt;

&lt;h3&gt;
  
  
  Python installation
&lt;/h3&gt;

&lt;p&gt;To have python run on the local machine, one has to install python from &lt;a href="https://www.python.org/"&gt;https://www.python.org/&lt;/a&gt;&lt;br&gt;
Or from any other source. &lt;br&gt;
Note: during python installation, an earlier version is preferred to the latest version.&lt;br&gt;
During python installation, it should be added to the path.&lt;br&gt;
Once python is installed, Editors should too be installed on the computer. Examples of editors include;&lt;br&gt;
Sublime, vscode, anaconda and extra.&lt;/p&gt;

&lt;p&gt;Writing a small program in python&lt;br&gt;
A program that outputs “lux-academy”&lt;br&gt;
print(‘lux-academy’)&lt;br&gt;
where print is a defined function in python used when outputting information, followed by paranthesis inside which a string to executed is place and in quotes.&lt;/p&gt;

&lt;h3&gt;
  
  
  variables
&lt;/h3&gt;

&lt;p&gt;Variables are reserved memory locations for storing values;&lt;br&gt;
int a = 9;&lt;br&gt;
a is a variable&lt;br&gt;
int is the data type&lt;br&gt;
9 is the value&lt;/p&gt;

&lt;h3&gt;
  
  
  Datatypes
&lt;/h3&gt;

&lt;p&gt;These are classifications of data items&lt;br&gt;
Data types include the following;&lt;br&gt;
• Numeric &lt;br&gt;
• Sequence Type &lt;br&gt;
• Boolean &lt;br&gt;
• Set &lt;br&gt;
• Dictionary &lt;/p&gt;

&lt;h3&gt;
  
  
  Keywords in python
&lt;/h3&gt;

&lt;p&gt;These are special reserved words. And thses include the following;&lt;br&gt;
For, if, def, or, else, class, while, break ….&lt;/p&gt;

&lt;h3&gt;
  
  
  Python operators:
&lt;/h3&gt;

&lt;p&gt;Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand.&lt;/p&gt;

&lt;p&gt;Operator include the following;&lt;br&gt;
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc.&lt;br&gt;
Operator    Meaning Example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Add two operands or unary plus  x + y+ 2&lt;/li&gt;
&lt;li&gt;  Subtract right operand from the left or unary minus x - y- 2&lt;/li&gt;
&lt;li&gt;  Multiply two operands   x * y
/   Divide left operand by the right one (always results into float)    x / y
%   Modulus - remainder of the division of left operand by the right    x % y (remainder of x/y)
//  Floor division - division that results into whole number adjusted to the left in the number line    x // y
**  Exponent - left operand raised to the power of right    x**y (x to the power y)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Comparison operator
&lt;/h3&gt;

&lt;p&gt;Comparison operators are used to compare values. It returns either True or False according to the condition.&lt;/p&gt;

&lt;p&gt;Operator    Meaning Example&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Greater than - True if left operand is greater than the right   x &amp;gt; y&lt;br&gt;
&amp;lt;   Less than - True if left operand is less than the right x &amp;lt; y&lt;br&gt;
==  Equal to - True if both operands are equal  x == y&lt;br&gt;
!=  Not equal to - True if operands are not equal   x != y&lt;br&gt;
=  Greater than or equal to - True if left operand is greater than or equal to the right   x &amp;gt;= y&lt;br&gt;
&amp;lt;=  Less than or equal to - True if left operand is less than or equal to the right x &amp;lt;= y&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Bitwise operators
&lt;/h3&gt;

&lt;p&gt;Bitwise operators act on operands as if they were strings of binary digits. They operate bit by bit, hence the name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Assignment operators
&lt;/h3&gt;

&lt;p&gt;Assignment operators are used in Python to assign values to variables.&lt;/p&gt;

&lt;p&gt;a = 5 is a simple assignment operator that assigns the value 5 on the right to the variable a on the left.&lt;/p&gt;

&lt;h3&gt;
  
  
  Identity operators
&lt;/h3&gt;

&lt;p&gt;is and is not are the identity operators in Python. They are used to check if two values (or variables) are located on the same part of the memory. Two variables that are equal does not imply that they are identical.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data structure
&lt;/h2&gt;

&lt;p&gt;A data structure is a specialized format for organizing, processing, retrieving and storing data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inbuilt data structures:
&lt;/h3&gt;

&lt;p&gt;Lists: these are mutable or items in the list can be changed&lt;br&gt;
Tuples: these are immutable. Meaning items in the tuple cannot be changed.&lt;br&gt;
Dictionary: is an ordered collection of data values, used to store data values like a map, which, unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized.&lt;br&gt;
Sets: A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements&lt;/p&gt;

&lt;p&gt;User-defined data structures;&lt;br&gt;
Queues&lt;br&gt;
Stacks &lt;br&gt;
Etc. &lt;br&gt;
Functions in python&lt;br&gt;
These are are blocks of organized re-usable set of instruction that are used in performing some related actions.&lt;br&gt;
 Recursive function. These are ones where the function calls itself. An example is when dealing with factorials.&lt;/p&gt;

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