<?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: Ambrose Otundo</title>
    <description>The latest articles on Forem by Ambrose Otundo (@ambroseotundo).</description>
    <link>https://forem.com/ambroseotundo</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%2F849459%2F2ef2a21a-86f5-47ac-8eb2-87f24264b938.png</url>
      <title>Forem: Ambrose Otundo</title>
      <link>https://forem.com/ambroseotundo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ambroseotundo"/>
    <language>en</language>
    <item>
      <title>User Management in Linux using a bash script</title>
      <dc:creator>Ambrose Otundo</dc:creator>
      <pubDate>Wed, 03 Jul 2024 19:15:25 +0000</pubDate>
      <link>https://forem.com/ambroseotundo/user-management-in-linux-using-a-bash-script-31l9</link>
      <guid>https://forem.com/ambroseotundo/user-management-in-linux-using-a-bash-script-31l9</guid>
      <description>&lt;p&gt;Managing users on Linux systems can be daunting, especially in environments with frequent changes. As part of my online internship at &lt;a href="https://dev.tourl"&gt;https://hng.tech/internship&lt;/a&gt;, I've been assigned a task to  develop a Bash script to automate this process. Let's dive into how this script works:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Initial Setup
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check if script is run with sudo&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This script must be run with sudo. Exiting..."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Redirect stdout and stderr to log file&lt;/span&gt;
&lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$LOG_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; 2&amp;gt;&amp;amp;1 
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Executing script... (note that this line will be logged twice)"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$LOG_FILE&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Input Validation
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check if an argument was provided&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$# &lt;/span&gt;&lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No file path provided."&lt;/span&gt; 
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt; &amp;lt;user-data-file-path&amp;gt;"&lt;/span&gt; 
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Check if the user's data file exists&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USERS_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The provided user's data file does not exist: &lt;/span&gt;&lt;span class="nv"&gt;$USERS_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Dependency Management
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Function to check if a package is installed&lt;/span&gt;
is_package_installed&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    dpkg &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&amp;gt;&amp;amp;1
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Check if openssl is installed&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; is_package_installed openssl&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"openssl is not installed. Installing..."&lt;/span&gt;
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; openssl
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Check if pwgen is installed&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; is_package_installed pwgen&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"pwgen is not installed. Installing..."&lt;/span&gt;
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; pwgen
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. File and Directory Management
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create the directory where the user's password file will be stored&lt;/span&gt;
&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD_FILE_DIRECTORY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# load the content of the users.txt file into an array: lines&lt;/span&gt;
&lt;span class="nb"&gt;mapfile&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; lines &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USERS_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. User Creation and Management
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# loop over each line in the array&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;line &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="c"&gt;# Remove leading and trailing whitespaces&lt;/span&gt;
    &lt;span class="nv"&gt;line&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | xargs&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Split line by ';' and store the second part&lt;/span&gt;
    &lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;';'&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; user &lt;span class="nb"&gt;groups&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="c"&gt;# Remove leading and trailing whitespaces from the second part&lt;/span&gt;
    &lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | xargs&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;groups&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$groups&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | xargs&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Check if user exists&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"User &lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt; already exists. Skipping creation."&lt;/span&gt;
        &lt;span class="k"&gt;continue
    fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  6. Password Handling
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate a 6-character password using pwgen&lt;/span&gt;
&lt;span class="nv"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;pwgen &lt;span class="nt"&gt;-sBv1&lt;/span&gt; 6 1&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Encrypt the password before storing it&lt;/span&gt;
&lt;span class="nv"&gt;encrypted_password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;encrypt_password &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD_ENCRYPTION_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Store the encrypted password in the file&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$encrypted_password&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  7. User and Group Operations
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create the user with the generated password&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;openssl passwd &lt;span class="nt"&gt;-6&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Set Bash as the default shell&lt;/span&gt;
set_bash_default_shell &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# loop over each group in the groups array&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;group &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;groupsArray&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;group&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | xargs&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Check if group exists, if not, create it&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"^&lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;:"&lt;/span&gt; /etc/group&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;groupadd &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Created group &lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;

    &lt;span class="c"&gt;# Add user to the group&lt;/span&gt;
    &lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Added &lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="s2"&gt; to &lt;/span&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  8. Conclusion and Cleanup
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# remove the created password from the current shell session&lt;/span&gt;
&lt;span class="nb"&gt;unset &lt;/span&gt;password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After completing this task and the follow-up tasks to stage 10 in the internship, I believe I will be ready for the job market in the DevOps field. If you are a hiring manager reading this article, you can get exceptional talent here &lt;a href="https://dev.toURL"&gt;https://hng.tech/hire&lt;/a&gt;. Thank you for reading my article. &lt;/p&gt;

&lt;p&gt;Author: Ambrose Onsare&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Move between words/text</title>
      <dc:creator>Ambrose Otundo</dc:creator>
      <pubDate>Tue, 09 Aug 2022 08:25:11 +0000</pubDate>
      <link>https://forem.com/ambroseotundo/move-between-wordstext-1k46</link>
      <guid>https://forem.com/ambroseotundo/move-between-wordstext-1k46</guid>
      <description>&lt;p&gt;Sometimes you have a large text in your phone and want to edit a typo or a word. You always try to click with your finger to that specific word. Its a hassle sometimes and there is a work around for that. Just press your space bar and move your finger from left to write and vice versa. This will move the cursor corresponding to your movement. Here is the video illustrating the same.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://www.youtube.com/shorts/m44VXhHgtAM?feature=share" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fgx_chNm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ytimg.com/vi/m44VXhHgtAM/hq2.jpg" height="360" class="m-0" width="480"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://www.youtube.com/shorts/m44VXhHgtAM?feature=share" rel="noopener noreferrer" class="c-link"&gt;
          video 2022 08 09 11 15 14 - YouTube
        &lt;/a&gt;
      &lt;/h2&gt;
        
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--1eZjw6XD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.youtube.com/s/desktop/a2197efa/img/favicon.ico" width="16" height="16"&gt;
        youtube.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>android</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>ios</category>
    </item>
    <item>
      <title>Creating Git Aliases</title>
      <dc:creator>Ambrose Otundo</dc:creator>
      <pubDate>Sun, 07 Aug 2022 11:43:00 +0000</pubDate>
      <link>https://forem.com/ambroseotundo/creating-git-aliases-3nng</link>
      <guid>https://forem.com/ambroseotundo/creating-git-aliases-3nng</guid>
      <description>&lt;p&gt;Sometimes you have gone through the hassle of writing the whole git commands in the git CLI. Let me now tell you that there is way to make that work easier. What is an alias? An alias is a &lt;strong&gt;shortcut that references a command&lt;/strong&gt;.Aliases are mostly used to replace long commands, improving efficiency and avoiding potential spelling errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create an alias&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your command line that can initialize a git cli. You can do that by using either &lt;em&gt;Windows terminal, git bash, CMD&lt;/em&gt; and writing &lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To define a Git alias, use the git config command with the alias and the command you want to substitute. For example, to create the alias &lt;code&gt;p&lt;/code&gt; for git &lt;code&gt;push&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global alias.p 'push'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Make sure you start each alias initilization with &lt;code&gt;git config --global&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;To check your git aliases simply type:&lt;br&gt;
&lt;code&gt;git config --global -l&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The above command will show this:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias.p=push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To use the just created alias just type:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Popular Git aliases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Git status&lt;/strong&gt;&lt;br&gt;
Git command line users often use the status command to see changed or untracked files. By default, this command provides verbose output with many lines, which you may not want or need. You can use a single alias to address both of these components: Define the alias &lt;code&gt;st&lt;/code&gt; to shorten the command with the option &lt;code&gt;-sb&lt;/code&gt; to output a less verbose status with branch information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.st 'status -sb'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use this alias on a clean branch, your output looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  git st
## main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using it on a branch with changed and untracked files produces this output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$ git st
## main
 M test2
?? test3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Git log --oneline&lt;/strong&gt;&lt;br&gt;
Create an alias to display your commits as single lines for more compact output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.ll 'log --oneline'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this alias provides a short list of all commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git ll
33559c5 (HEAD -&amp;gt; main) Another commit
17646c1 test1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Git last commit&lt;/strong&gt;&lt;br&gt;
This shows details about the most recent commit you made.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.last 'log -1 HEAD --stat'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use it to see the last commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git last
commit f3dddcbaabb928f84f45131ea5be88dcf0692783 (HEAD -&amp;gt; branch1)
Author: ambrose &amp;lt;ambrose@hello.com&amp;gt;
Date:   Sun Jun 3 00:12:22 2022 +0000

    Commit to branch1

 test2 | 1 +
 test3 | 0
 2 files changed, 1 insertion(+)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Git commit&lt;/strong&gt;&lt;br&gt;
You use git commit a lot when you're making changes to a Git repository. Make the &lt;code&gt;git commit -m&lt;/code&gt; command more efficient with the &lt;code&gt;cm&lt;/code&gt; alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.cm 'commit -m'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because Git aliases expand commands, you can provide additional parameters during their execution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git cm "Just a commit message"
[branch1 0baa729] Just a commit message
 2 file changed, 3 insertions(+)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Git remote&lt;/strong&gt;&lt;br&gt;
The git remote -v command lists all configured remote repositories. Shorten it with the alias &lt;code&gt;rv&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;$ git config --global alias.rv 'remote -v'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Git diff&lt;/strong&gt;&lt;br&gt;
The git diff command displays differences between files in different commits or between a commit and the working tree. Simplify it with the &lt;code&gt;d&lt;/code&gt; alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.d 'diff'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The standard git diff command works fine for small changes. But for more complex ones, an external tool such as &lt;code&gt;vimdiff&lt;/code&gt; makes it more useful. Create the alias dv to display diffs using &lt;code&gt;vimdiff&lt;/code&gt;and use the &lt;code&gt;-y&lt;/code&gt; parameter to skip the confirmation prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.dv 'difftool -t vimdiff -y'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this alias to display file1 differences between two commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git dv 33559c5 ca1494d file1
vim-diff results
(hello there)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Git config list&lt;/strong&gt;&lt;br&gt;
The gl alias makes it easier to list all user configurations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global alias.gl 'config --global -l'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can see all defined aliases (and other configuration options):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git gl
user.name=ricardo
user.email=ricardo@example.com
alias.p=push
alias.st=status -sb
alias.ll=log --oneline
alias.last=log -1 HEAD --stat
alias.cm=commit -m
alias.rv=remote -v
alias.d=diff
alias.dv=difftool -t vimdiff -y
alias.gl=config --global -l
alias.se=!git rev-list --all | xargs git grep -F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you go. You can also check on more commands in the GIT documentation and make cool aliases.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>Python Main Function</title>
      <dc:creator>Ambrose Otundo</dc:creator>
      <pubDate>Sun, 07 Aug 2022 11:03:35 +0000</pubDate>
      <link>https://forem.com/ambroseotundo/python-main-function-3m4g</link>
      <guid>https://forem.com/ambroseotundo/python-main-function-3m4g</guid>
      <description>&lt;p&gt;Those who have coded in for example in C have interacted with the &lt;a href="https://en.cppreference.com/w/c/language/main_function"&gt;&lt;strong&gt;main()&lt;/strong&gt;&lt;/a&gt; function. In python we also have the main() function but its declaration is somehow different .The &lt;strong&gt;Main function&lt;/strong&gt; is like the entry point of a program. However, Python interpreters run the code right from the first line. The execution of the code starts from the starting line and goes line by line. It does not matter where the main function is present or it is present or not.&lt;/p&gt;

&lt;p&gt;Since there is no main() function in Python, when the command to run a Python program is given to the interpreter, the code that is at level 0 indentation is to be executed. However, before doing that, it will define a few special variables. &lt;code&gt;__name__&lt;/code&gt;is one such special variable. If the source file is executed as the main program, the interpreter sets the &lt;code&gt;__name__&lt;/code&gt; variable to have a value &lt;code&gt;__main__&lt;/code&gt;. If this file is being imported from another module, &lt;code&gt;__name__&lt;/code&gt; will be set to the module’s name.&lt;br&gt;
&lt;code&gt;__name__&lt;/code&gt; is a built-in variable which evaluates to the name of the current module.&lt;br&gt;
Lets look at an &lt;strong&gt;example:&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;# Python program to demonstrate
# main() function


print("Hello")

# Defining main function
def main():
    print("hey there")


# Using the special variable
# __name__
if __name__=="__main__":
    main()

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

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Hello&lt;br&gt;
hey there&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
When above program is executed, the interpreter declares the initial value of name as “main”. When the interpreter reaches the if statement it checks for the value of name and when the value of if is true it runs the main function else the main function is not executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main function as Module&lt;/strong&gt;&lt;br&gt;
Now when we import a Python script as module the &lt;code&gt;__name__&lt;/code&gt; variable gets the value same as the name of the python script imported.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example2:&lt;/strong&gt; Let’s consider there are two Files(File1.py and File2.py). File1 is as follow.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;# File1.py *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("File1 __name__ = %s" %__name__)

if __name__ == "__main__": 
    print("File1 is being run directly")
else: 
    print("File1 is being imported")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


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

&lt;p&gt;&lt;code&gt;File1 __name__ = __main__&lt;/code&gt;&lt;br&gt;
File1 is being run directly&lt;br&gt;
Now, when the File1.py is imported into File2.py, the value of &lt;code&gt;__name__&lt;/code&gt; changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# File2.py&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;import File1 

print("File2 __name__ = %s" %__name__)

if __name__ == "__main__":
    print("File2 is being run directly")
else: 
    print("File2 is being imported"){% embed  %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


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

&lt;p&gt;&lt;code&gt;File1 __name__ = File1&lt;br&gt;
File1 is being imported&lt;br&gt;
File2 __name__ = __main__&lt;br&gt;
File2 is being run directly&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As seen above, when File1.py is run directly, the interpreter sets the &lt;code&gt;__name__&lt;/code&gt;variable as &lt;code&gt;__main__&lt;/code&gt; and when it is run through File2.py by importing, the &lt;strong&gt;name&lt;/strong&gt; variable is set as the name of the python script, i.e. File1. Thus, it can be said that if &lt;code&gt;__name__ == “__main__”&lt;/code&gt; is the part of the program that runs when the script is run from the command line using a command like Python File1.py.&lt;br&gt;
There you have it.&lt;br&gt;
You can visit the docs here for more info:&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://docs.python.org/3/library/__main__.html" rel="noopener noreferrer"&gt;
      docs.python.org
    &lt;/a&gt;
&lt;/div&gt;



</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python 101 : The Ultimate Python Tutorial For Beginners By Ambrose</title>
      <dc:creator>Ambrose Otundo</dc:creator>
      <pubDate>Sun, 24 Apr 2022 11:39:28 +0000</pubDate>
      <link>https://forem.com/ambroseotundo/python-101-the-ultimate-python-tutorial-for-beginners-by-ambrose-d5n</link>
      <guid>https://forem.com/ambroseotundo/python-101-the-ultimate-python-tutorial-for-beginners-by-ambrose-d5n</guid>
      <description>&lt;p&gt;What actually is Python Programming language? I know you've heard of it and had that notion that it is linked to a land reptile. Python is a an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The basic question that most beginners have in mind is what a language can do. Here are some of the use-cases of Python:&lt;/p&gt;

&lt;p&gt;Server-side development ( Django, Flask )&lt;br&gt;
Data Science ( Pytorch, Tensor-flow )&lt;br&gt;
Data analysis / Visualisation ( Matplotlib )&lt;br&gt;
Scripting ( Beautiful Soup )&lt;br&gt;
Embedded development&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;u&gt;Lets dive in on how to first install python in your computer.&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing Python on Windows&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to Python's official website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the download button ( Download Python 3.10 )&lt;br&gt;&lt;br&gt;
_Note: The version may differ based on when you are reading this article _&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to the path where the package is downloaded and double-click the installer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check the box indicating to "Add Python 3.x to PATH" and then click on "Install Now".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once done you'll get a prompt that "Setup was successful". Check again if python is configured properly using the above command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To confirm if Python is installed and configured properly, use the command python.&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;python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installing on MacoS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First install xcode from the app store.&lt;br&gt;
If you want to install Xcode using the terminal then use the following command:&lt;br&gt;
&lt;code&gt;xcode-select --install&lt;/code&gt;&lt;br&gt;
After that, we will use the brew package manager to install Python. To install and configure brew, use the following command:&lt;br&gt;
&lt;code&gt;/bin/bash -c "$(curl -fsSL&lt;/code&gt;&lt;code&gt;https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"&lt;/code&gt;&lt;br&gt;
Once brew setup is done, use the following command to update any outdated packages:&lt;br&gt;
&lt;code&gt;brew update&lt;/code&gt;&lt;br&gt;
Use the following command to install Python:&lt;br&gt;
&lt;code&gt;brew install python3&lt;/code&gt;&lt;br&gt;
To confirm if Python is installed and configured properly, use the command&lt;br&gt;
&lt;code&gt;python&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing on Linux&lt;/strong&gt;&lt;br&gt;
install Python using &lt;code&gt;apt&lt;/code&gt;, use the following command:&lt;br&gt;
&lt;code&gt;sudo apt install python3&lt;/code&gt;&lt;br&gt;
To install the Python using yum, use the following command:&lt;br&gt;
&lt;code&gt;sudo yum install python3&lt;/code&gt;&lt;br&gt;
To confirm if Python is installed and configured properly, use the command&lt;br&gt;
 &lt;code&gt;python3 --version.&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Python Shell
&lt;/h2&gt;

&lt;p&gt;The Python Shell is the interpreter that executes your Python programs, other pieces of Python code, or simple commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--veyQXI6f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6adsazc4kp84et755m0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--veyQXI6f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6adsazc4kp84et755m0.png" alt="Image description" width="876" height="92"&gt;&lt;/a&gt;&lt;br&gt;
For Example:&lt;br&gt;
We can do a simple math calculation in the shell. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rVEtFfXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/il8qpxhbdtqnxgipmpe5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rVEtFfXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/il8qpxhbdtqnxgipmpe5.png" alt="Image description" width="880" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commenting:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Comments make it easy to write code as they help us (and others) understand why a particular piece of code was written. Another awesome thing about comments is that they help improve the readability of the code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oSmYVrM1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8neb1n0ulibv1ujmomrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oSmYVrM1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8neb1n0ulibv1ujmomrm.png" alt="Image description" width="280" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Indentation&lt;/strong&gt;:&lt;br&gt;
It is compulsory in Python to follow the rules of indentation. If proper indentation is not followed you'll get the following error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kB6GIkUz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypi8dr1zh468exqfgdq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kB6GIkUz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypi8dr1zh468exqfgdq2.png" alt="Image description" width="419" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Variables:&lt;br&gt;
As the name implies, a variable is something that can change. A variable is a way of referring to a memory location used by a computer program.&lt;/p&gt;

&lt;p&gt;Well in most programming languages you need to assign the type to a variable. But in Python, you don’t need to. For example, to declare an integer in C, the following syntax 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;int num = 5;. In Python it's num = 5 .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to the Python shell and perform the operation step by step:&lt;/p&gt;

&lt;p&gt;Integer: Numerical values that can be positive, negative, or zero without a decimal point.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;As you can see here we have declared a &lt;code&gt;num&lt;/code&gt; variable and assigned &lt;code&gt;5&lt;/code&gt;as a value. Python's inbuilt  type method can be used to check the type of variable. When we check the type of &lt;code&gt;num&lt;/code&gt; we see the output  &lt;code&gt;&amp;lt;class 'int'&amp;gt;&lt;/code&gt;. For now, just focus on the &lt;code&gt;int&lt;/code&gt; in that output. &lt;code&gt;int&lt;/code&gt; represents an integer.&lt;/p&gt;

&lt;p&gt;Float: Similar an integer but with one slight difference – &lt;code&gt;floats&lt;/code&gt; are a numerical value with a decimal place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; num = 5.0
&amp;gt;&amp;gt;&amp;gt; print(num)
5.0
&amp;gt;&amp;gt;&amp;gt; type(num)
&amp;lt;class 'float'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have assigned a number with a single decimal to the num. When we check the type of &lt;code&gt;num&lt;/code&gt; we can see it is float.&lt;/p&gt;

&lt;p&gt;String: A formation of characters or integers. They can be represented using double or single quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "Hello user"
&amp;gt;&amp;gt;&amp;gt; print(greet)
Hello user
&amp;gt;&amp;gt;&amp;gt; type(greet)
&amp;lt;class 'str'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have assigned a string to greet. The type of greet is a string as you can see from the output.&lt;/p&gt;

&lt;p&gt;Boolean: A binary operator with a True or False value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_available = True
&amp;gt;&amp;gt;&amp;gt; print(is_available)
True
&amp;gt;&amp;gt;&amp;gt; type(is_available)
&amp;lt;class 'bool'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have assigned a True value to &lt;code&gt;is_available&lt;/code&gt;. The type of this variable is &lt;em&gt;boolean&lt;/em&gt;. You can only assign True or False. Remember T and F should be capital or it will give an error as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_available = true
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
NameError: name 'true' is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NoneType: This is used when we don't have the value of the variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; num = None
&amp;gt;&amp;gt;&amp;gt; print(num)
None
&amp;gt;&amp;gt;&amp;gt; type(num)
&amp;lt;class 'NoneType'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Operators:&lt;/strong&gt;&lt;br&gt;
These are Arithmetic operators available in Python.&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WRJnXZ1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kg47l6yfqt7rnvd24n2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WRJnXZ1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kg47l6yfqt7rnvd24n2i.png" alt="Image description" width="880" height="613"&gt;&lt;/a&gt;&lt;br&gt;
Lets look at their functionality.&lt;/p&gt;

&lt;p&gt;Arithmetic operators&lt;br&gt;
These include addition, subtraction, deletion, exponentiation, modulus, and floor division. Also the shorthand syntax for some operators.&lt;/p&gt;

&lt;p&gt;First, we will declare two variables, &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&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;&amp;gt;&amp;gt;&amp;gt; a = 6 # Assignment
&amp;gt;&amp;gt;&amp;gt; b = 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's try our basic arithmetic operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a + b # Addition
8
&amp;gt;&amp;gt;&amp;gt; a - b # Subtraction
4
&amp;gt;&amp;gt;&amp;gt; a * b # Multiplication
12
&amp;gt;&amp;gt;&amp;gt; a / b # Division
3.0
&amp;gt;&amp;gt;&amp;gt; a ** b # Exponentiation
36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test for other arithmetic operations let's change the value of a and b.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 7
&amp;gt;&amp;gt;&amp;gt; b = 3
&amp;gt;&amp;gt;&amp;gt; a % b # Modulus
1
&amp;gt;&amp;gt;&amp;gt; a // b # Floor division
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Comparison operators&lt;br&gt;
These include equal to, greater than, and less than.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 5 # Assign
&amp;gt;&amp;gt;&amp;gt; b = 2 # Assign
&amp;gt;&amp;gt;&amp;gt; a &amp;gt; b # Greater than
True
&amp;gt;&amp;gt;&amp;gt; a &amp;lt; b # less then
False
&amp;gt;&amp;gt;&amp;gt; a == b # Equal to
False
&amp;gt;&amp;gt;&amp;gt; a &amp;gt;= 5 # Greater than or equal to
True
&amp;gt;&amp;gt;&amp;gt; b &amp;lt;= 1 # Less than or equal to
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logical operators&lt;br&gt;
These operators include &lt;code&gt;not&lt;/code&gt;, &lt;code&gt;and&lt;/code&gt;, &amp;amp; &lt;code&gt;or&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;&amp;gt;&amp;gt;&amp;gt; a = 10
&amp;gt;&amp;gt;&amp;gt; b = 2
&amp;gt;&amp;gt;&amp;gt; a == 2 and b == 10 # and
False
&amp;gt;&amp;gt;&amp;gt; a == 10 or b == 10 # or
True
&amp;gt;&amp;gt;&amp;gt; not(a == 10) # not
False
&amp;gt;&amp;gt;&amp;gt; not(a == 2)
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conditional Statements:&lt;br&gt;
Conditional statements are used to evaluate if a condition is true or false.&lt;/p&gt;

&lt;p&gt;Many times when you are developing an application you need to check a certain condition and do different things depending on the outcome. In such scenarios conditional statements are useful. &lt;code&gt;If&lt;/code&gt;, &lt;code&gt;elif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; are the conditional statements used in Python.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We can compare variables, check if the variable has any value or if it's a boolean, then check if it's true or false. Go to the Python shell and perform the operation step by step:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Condition Number 1&lt;/strong&gt;: We have an integer and 3 conditions here. The first one is the if condition. It checks if the number is equal to 10.&lt;/p&gt;

&lt;p&gt;The second one is the elif condition. Here we are checking if the number is less than 10.&lt;/p&gt;

&lt;p&gt;The last condition is else. This condition executes when none of the above conditions match.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; number = 5
&amp;gt;&amp;gt;&amp;gt; if number == 10:
...     print("Number is 10")
... elif number &amp;lt; 10:
...     print("Number is less than 10")
... else:
...     print("Number is more than 10")
...
&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;Number is less than 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: It is not compulsory to check that two conditions are equal in the if condition. You can do it in the elif also.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Condition Number 2&lt;/strong&gt;: We have a boolean and 2 conditions here. Have you noticed how we are checking if the condition is true? If is_available, then print "Yes it is available", else print "Not available".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_available = True
&amp;gt;&amp;gt;&amp;gt; if is_available:
...     print("Yes it is available")
... else:
...     print("Not available")
...
&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;Yes it is available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Condition Number 3&lt;/strong&gt;: Here we have reversed condition number 2 with the help of the not operator.&lt;/p&gt;

&lt;blockquote&gt;

&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; is_available = True
&amp;gt;&amp;gt;&amp;gt; if not is_available:
...     print("Not available")
... else:
...     print("Yes it is available")
...
&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;Yes it is available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Condition Number 4&lt;/strong&gt;: Here we are declaring the data as None and checking if the data is available or not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; data = None
&amp;gt;&amp;gt;&amp;gt; if data:
...     print("data is not none")
... else:
...     print("data is none")
...
&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;data is none
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;br&gt;
For Loops:**&lt;br&gt;
Another useful method in any programming language is an iterator. If you have to implement something multiple times, what will you do?&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")
print("Hello")
print("Hello")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, that's one way to do it. But imagine you have to do it a hundred or a thousand times. Well, that's a lot of print statements we have to write. There's a better way called iterators or loops. We can either use a for or while loop.&lt;/p&gt;

&lt;p&gt;Here we are using the range method. It specifies the range until which the loop should be repeated. By default, the starting point is 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(3):
...     print("Hello")
...
&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;Hello
Hello
Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also specify the range in this way range(1,3).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(1,3):
...     print("Hello")
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Hello&lt;br&gt;
Hello&lt;br&gt;
"Hello" is only printed two times as we have specified the range here. Think of the range as Number on right - Number on left.&lt;/p&gt;

&lt;p&gt;Well, you can also add an else statement in the for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(3):
...     print("Hello")
... else:
...     print("Finished")
&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;Hello
Hello
Hello
Finished
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also nest a for loop inside another for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(3):
...     for j in range(2):
...             print("Inner loop")
...     print("Outer loop")
...
&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;Inner loop
Inner loop
Outer loop
Inner loop
Inner loop
Outer loop
Inner loop
Inner loop
Outer loop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see the inner loop print statement executed two times. After that outer loop print statement executed. Again the inner loop executed two times. So what is happening here? If you are confused then consider this to solve it:&lt;/p&gt;

&lt;p&gt;Our Interpreter comes and sees that there is a for loop. It goes down again and checks there is another for loop.&lt;br&gt;
So now it will execute the inner for loop two times and exit. Once it's finished it knows that outer for loop has instructed it to repeat two more times.&lt;br&gt;
It starts again and sees the inner for loop and repeats.&lt;br&gt;
Well, you can also choose to pass a certain for loop condition. What does pass mean here? Well whenever that for loop will occur and the Interpreter sees the pass statement it won't execute it and will move to the next line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(3):
...     pass
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will not get any output on the shell.&lt;/p&gt;

&lt;p&gt;While loops:&lt;br&gt;
Another loop or iterator available in Python is the while loop. We can achieve some of the same results with the help of a while loop as we achieved with the for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 5:
...     print("Number", i)
...     i += 1
...
&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;Number 0
Number 1
Number 2
Number 3
Number 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember whenever you use a while loop it's important that you add an increment statement or a statement that will end the while loop at some point. If not then the while loop will execute forever.&lt;/p&gt;

&lt;p&gt;Another option is to add a break statement in a while loop. This will break the loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 5:
...     if i == 4:
...             break
...     print("Number", i)
...     i += 1
...
&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;Number 0
Number 1    
Number 2
Number 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are breaking the while loop if we find the value of i to be 4.&lt;/p&gt;

&lt;p&gt;Another option is to add an else statement in while loop. The statement will be executed after the while loop is completed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 5:
...     print("Number", i)
...     i += 1
... else:
...     print("Number is greater than 4")
...
&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;Number 0
Number 1
Number 2
Number 3
Number 4
Number is greater than 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;User Input:&lt;br&gt;
Imagine you are building a command-line application. Now you have to take the user input and act accordingly. To do that you can use Python's inbuilt input method.&lt;/p&gt;

&lt;p&gt;The syntax to achieve this is as follows:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;variable = input(".....")&lt;/code&gt;&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; name = input("Enter your name: ")
Enter your name: Ambrose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you use the input  method and press enter, you'll be prompted with the text that you enter in the input method. Let's check if our assignment is working or not:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This tutorial will give a first hand experience on starting to code with Python. I hope you guys have a blast coding.&lt;br&gt;
Happy coding :)&lt;/p&gt;

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