<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vikas on Medium]]></title>
        <description><![CDATA[Stories by Vikas on Medium]]></description>
        <link>https://medium.com/@vikas234mv?source=rss-08160f2e2e71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xG-FrlJQKZ7J48JBReDr_g.jpeg</url>
            <title>Stories by Vikas on Medium</title>
            <link>https://medium.com/@vikas234mv?source=rss-08160f2e2e71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 16:35:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vikas234mv/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Calculate the Sum of Digits in Python]]></title>
            <link>https://medium.com/@vikas234mv/how-to-calculate-the-sum-of-digits-in-python-dd3a6e79bb34?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd3a6e79bb34</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 02:15:55 GMT</pubDate>
            <atom:updated>2026-11-16T02:15:55.657Z</atom:updated>
            <content:encoded><![CDATA[<p>Calculating the sum of digits is one of the most common beginner-level programming problems in Python. In this tutorial, we will learn how to calculate the sum of digits of a number using Python with different approaches and practical examples.</p><h3><strong>What Is the Sum of Digits?</strong></h3><p>The sum of digits means adding all the individual digits of a number together.</p><h4><strong>Example:</strong></h4><p>Consider the number 1234.</p><blockquote>First digit: 1</blockquote><blockquote>Second digit: 2</blockquote><blockquote>Third digit: 3</blockquote><blockquote>Fourth digit: 4</blockquote><h4><strong>Calculation:</strong></h4><p>1 + 2 + 3 + 4 = 10</p><h4><strong>Output:</strong></h4><p>Enter a number: 1234</p><p>Sum of digits: 10</p><h3><strong>Method 1: Using a While Loop</strong></h3><p>The while loop is one of the easiest ways to calculate the sum of digits in Python.</p><p>We can use the modulo (%) operator to extract the last digit and the floor division (//) operator to remove the last digit.</p><h4><strong>Python Program:</strong></h4><pre>num = int(input(&quot;Enter a number: &quot;))<br>total = 0<br>while num &gt; 0:<br>digit = num % 10<br>total += digit<br>num = num // 10<br>print(&quot;Sum of digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Enter a number: 1234</p><p>Sum of digits: 10</p><h3><strong>Method 2: Using a For Loop</strong></h3><p>We can also calculate the sum of digits using a for loop by converting the number into a string.</p><h4><strong>Python Program:</strong></h4><pre>num = input(&quot;Enter a number: &quot;)<br>total = 0<br>for digit in num:<br>total += int(digit)<br>print(&quot;Sum of digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Enter a number: 5678</p><p>Sum of digits: 26</p><h3><strong>Method 3: Using a Function</strong></h3><p>In Python, we can create a user-defined function to calculate the sum of digits. This approach makes the code reusable.</p><h4><strong>Python Program:</strong></h4><pre>def sum_of_digits(num):<br>total = 0<br>while num &gt; 0:<br>digit = num % 10<br>total += digit<br>num //= 10<br>return total<br>number = int(input(&quot;Enter a number: &quot;))<br>result = sum_of_digits(number)<br>print(&quot;Sum of digits:&quot;, result)</pre><p><strong>Output:</strong></p><p>Enter a number: 9876</p><p>Sum of digits: 30</p><h3><strong>Method 4: Using the Built-in sum() Function</strong></h3><p>Python provides a built-in sum() function that can add values from an iterable. We can use it with a generator expression to calculate the sum of digits.</p><h4><strong>Python Program:</strong></h4><pre>num = input(&quot;Enter a number: &quot;)<br>total = sum(int(digit) for digit in num)<br>print(&quot;Sum of digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Enter a number: 4567</p><p>Sum of digits: 22</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd3a6e79bb34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Simple Calculator Using Python Variables]]></title>
            <link>https://python.plainenglish.io/build-a-simple-calculator-using-python-variables-829ecae2b9e1?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/829ecae2b9e1</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 10:28:39 GMT</pubDate>
            <atom:updated>2026-11-13T10:28:39.163Z</atom:updated>
            <content:encoded><![CDATA[<p>A calculator is one of the easiest and most useful Python projects for beginners. It helps you understand how Python variables, arithmetic operators and conditional statements. By creating a simple calculator, you can learn how to perform basic mathematical operations such as addition, subtraction, multiplication and division.</p><p>In this article, we will learn how to build a simple calculator using Python variables with an easy-to-understand example.</p><h3><strong>Python Program to Build a Simple Calculator Using Variables</strong></h3><p>Let’s create a simple calculator that accepts two numbers and an arithmetic operator from the user.</p><h4><strong>Python Code:</strong></h4><pre># Simple Calculator Using Python Variables<br>num1 = float(input(&quot;Enter first number: &quot;))<br>operator = input(&quot;Enter operator (+, -, *, /): &quot;)<br>num2 = float(input(&quot;Enter second number: &quot;))<br>if operator == &quot;+&quot;:<br>result = num1 + num2<br>print(&quot;Result:&quot;, result)<br>elif operator == &quot;-&quot;:<br>result = num1 - num2<br>print(&quot;Result:&quot;, result)<br>elif operator == &quot;*&quot;:<br>result = num1 * num2<br>print(&quot;Result:&quot;, result)<br>elif operator == &quot;/&quot;:<br>if num2 != 0:<br>result = num1 / num2<br>print(&quot;Result:&quot;, result)<br>else:<br>print(&quot;Error: Cannot divide by zero&quot;)<br>else:<br>print(&quot;Invalid operator&quot;)</pre><h4><strong>Output :</strong></h4><h4><strong>Example 1: Addition</strong></h4><p>Enter first number: 20</p><p>Enter operator (+, -, *, /): +</p><p>Enter second number: 10</p><p>Result: 30.0</p><h4><strong>Example 2: Subtraction</strong></h4><p>Enter first number: 50</p><p>Enter operator (+, -, *, /): -</p><p>Enter second number: 20</p><p>Result: 30.0</p><h4><strong>Example 3: Multiplication</strong></h4><p>Enter first number: 10</p><p>Enter operator (+, -, *, /): *</p><p>Enter second number: 5</p><p>Result: 50.0</p><h4><strong>Example 4: Division</strong></h4><p>Enter first number: 100</p><p>Enter operator (+, -, *, /): /</p><p>Enter second number: 4</p><p>Result: 25.0</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=829ecae2b9e1" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/build-a-simple-calculator-using-python-variables-829ecae2b9e1">Build a Simple Calculator Using Python Variables</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Python Variable Examples Every Beginner Should Know]]></title>
            <link>https://python.plainenglish.io/5-python-variable-examples-every-beginner-should-know-938671b4b3d8?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/938671b4b3d8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 07:10:19 GMT</pubDate>
            <atom:updated>2026-11-13T07:12:44.768Z</atom:updated>
            <content:encoded><![CDATA[<p>Variables are one of the most important concepts in Python programming. A variable is a name used to store data in a program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsmYwFu7R41l_RErAyk_Yw.png" /><figcaption>5 Python Variable Examples Every Beginner Should Know</figcaption></figure><p>For example:</p><pre>name = &quot;abc&quot;<br>age = 25<br>price = 499.99<br>print(name)<br>print(age)<br>print(price)</pre><p><strong>Output:</strong></p><p>abc</p><p>25</p><p>499.99</p><p>In this article, we will explore 5 simple Python variable examples that every beginner should know.</p><h3><strong>1. Python Variable Example with a String</strong></h3><p>A string variable is used to store text values. Strings are written single or double quotation.</p><h4><strong>Example:</strong></h4><pre>name = &quot;Python Programming&quot;<br>print(name)</pre><p><strong>Output:</strong></p><p>Python Programming</p><p><strong>Explanation:</strong> The variable name stores the text “Python Programming”. The print() function displays the stored value.</p><h3><strong>2. Python Variable Example with an Integer</strong></h3><p>An integer variable stores whole numbers without decimal points.</p><h4><strong>Example:</strong></h4><pre>age = 25<br>print(age)</pre><p><strong>Output:</strong></p><p>25</p><p><strong>Explanation:</strong> The variable age stores the integer value 25.</p><h3><strong>3. Python Variable Example with a Float</strong></h3><p>A float variable stores numbers that contain decimal points.</p><h4><strong>Example:</strong></h4><pre>price = 299.50<br>print(price)</pre><p><strong>Output:</strong></p><p>299.5</p><p><strong>Explanation:</strong> The variable price stores a floating-point number.</p><h3><strong>4. Python Variable Example with a Boolean</strong></h3><p>A Boolean variable stores either True or False.</p><h4><strong>Example:</strong></h4><pre>is_abc = True<br>print(is_abc)</pre><p><strong>Output:</strong></p><p>True</p><h3><strong>5. Python Variable Example with Multiple Variables</strong></h3><p>Python allows programmers to assign values to multiple variables in a single statement.</p><h4><strong>Example:</strong></h4><pre>name, age, city = &quot;kumar&quot;, 22, &quot;Bangalore&quot;<br>print(name)<br>print(age)<br>print(city)</pre><p><strong>Output:</strong></p><p>kumar</p><p>22</p><p>Bangalore</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=938671b4b3d8" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/5-python-variable-examples-every-beginner-should-know-938671b4b3d8">5 Python Variable Examples Every Beginner Should Know</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Print Multiples of 5]]></title>
            <link>https://python.plainenglish.io/python-program-to-print-multiples-of-5-a3b15d2d1353?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3b15d2d1353</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 04:43:11 GMT</pubDate>
            <atom:updated>2026-11-13T04:43:11.812Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, we can print multiples of 5 using loops, conditional statements, and arithmetic operators.</p><p>Multiples of 5 are numbers obtained by multiplying 5 by an integer.</p><blockquote>For example:</blockquote><blockquote>5 × 1 = 5</blockquote><blockquote>5 × 2 = 10</blockquote><blockquote>5 × 3 = 15</blockquote><blockquote>5 × 4 = 20</blockquote><blockquote>5 × 5 = 25</blockquote><p>Therefore, the first five multiples of 5 are 5, 10, 15, 20, and 25.</p><p>In this article, we will learn how to write a Python program to print multiples of 5 using different methods.</p><h3><strong>Python Program to Print Multiples of 5</strong></h3><p>The following program uses a for loop and the range() function to print the first 10 multiples of 5.</p><h4><strong>Program :</strong></h4><pre>for i in range(1, 11):<br>print(5 * i)</pre><p><strong>Output :</strong></p><p>5</p><p>10</p><p>15</p><p>20</p><p>25</p><p>30</p><p>35</p><p>40</p><p>45</p><p>50</p><h3><strong>Different Methods to Print Multiples of 5 in Python</strong></h3><p>Python provides several ways to print multiples of 5. Let’s explore some common approaches.</p><h4><strong>1. Using a For Loop :</strong></h4><p>A for loop is one of the simplest ways to print multiples of 5.</p><pre>for i in range(1, 6):<br>print(5 * i)</pre><p><strong>Output:</strong></p><p>5</p><p>10</p><p>15</p><p>20</p><p>25</p><h4><strong>2. Using a While Loop :</strong></h4><p>We can also use a while loop to print multiples of 5.</p><pre>i = 1<br>while i &lt;= 10:<br>print(5 * i)<br>i += 1</pre><p><strong>Output:</strong></p><p>5</p><p>10</p><p>15</p><p>20</p><p>25</p><p>30</p><p>35</p><p>40</p><p>45</p><p>50</p><h4><strong>3. Using a Function :</strong></h4><p>A function makes the program reusable. We can call the same function whenever we need to print multiples of 5.</p><pre>def print_multiples(n):<br>for i in range(1, n + 1):<br>print(5 * i)<br>print_multiples(10)</pre><p><strong>Output:</strong></p><p>5</p><p>10</p><p>15</p><p>20</p><p>25</p><p>30</p><p>35</p><p>40</p><p>45</p><p>50</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3b15d2d1353" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-print-multiples-of-5-a3b15d2d1353">Python Program to Print Multiples of 5</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Find the Sum of Odd Digits]]></title>
            <link>https://python.plainenglish.io/python-program-to-find-the-sum-of-odd-digits-70b83da2d0c8?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/70b83da2d0c8</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 04:38:12 GMT</pubDate>
            <atom:updated>2026-11-13T04:38:12.905Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, we can find the sum of all odd digits in a number using loops, conditional statements, and arithmetic operators.</p><p>An odd digit is a digit that is not divisible by 2. The odd digits are 1, 3, 5, 7, and 9.</p><blockquote>For example, consider the number 123456789:</blockquote><blockquote>Odd digits: 1, 3, 5, 7, 9</blockquote><blockquote>Sum = 1 + 3 + 5 + 7 + 9</blockquote><blockquote>Result = 25</blockquote><p>In this article, we will learn how to write a Python program to find the sum of odd digits in a number using different methods.</p><h3><strong>Python Program to Find the Sum of Odd Digits</strong></h3><p>The following program accepts a number from the user and calculates the sum of all its odd digits using a while loop.</p><h4><strong>Program :</strong></h4><pre>num = int(input(&quot;Enter a number: &quot;))<br>num = abs(num)<br>total = 0<br>while num &gt; 0:<br>digit = num % 10<br>if digit % 2 != 0:<br>total += digit<br>num //= 10<br>print(&quot;Sum of odd digits:&quot;, total)</pre><p><strong>Output :</strong></p><p>Enter a number: 123456789</p><p>Sum of odd digits: 25</p><h3><strong>Different Methods to Find the Sum of Odd Digits in Python</strong></h3><p>Python provides several ways to solve this problem. Let’s explore some common approaches.</p><h4><strong>1. Using a While Loop :</strong></h4><p>A while loop is one of the simplest ways to extract each digit and check whether it is odd.</p><pre>num = 987654<br>total = 0<br>while num &gt; 0:<br>digit = num % 10<br>if digit % 2 == 1:<br>total += digit<br>num //= 10<br>print(&quot;Sum of odd digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Sum of odd digits: 21</p><h4><strong>2. Using a For Loop :</strong></h4><p>We can convert the number into a string and use a for loop to access each digit.</p><pre>num = input(&quot;Enter a number: &quot;)<br>total = 0<br>for digit in num.lstrip(&quot;-&quot;):<br>digit = int(digit)<br>if digit % 2 != 0:<br>total += digit<br>print(&quot;Sum of odd digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Enter a number: 12345</p><p>Sum of odd digits: 9</p><p>Here, the odd digits are 1, 3, and 5. Their sum is 9.</p><h4><strong>3. Using a Function :</strong></h4><p>We can define a function to calculate the sum of odd digits. This makes the code reusable for different numbers.</p><pre>def sum_odd_digits(num):<br>num = abs(num)<br>total = 0<br>while num &gt; 0:<br>digit = num % 10<br>if digit % 2 != 0:<br>total += digit<br>num //= 10<br>return total<br>result = sum_odd_digits(123456789)<br>print(&quot;Sum of odd digits:&quot;, result)</pre><p><strong>Output:</strong></p><p>Sum of odd digits: 25</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70b83da2d0c8" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-find-the-sum-of-odd-digits-70b83da2d0c8">Python Program to Find the Sum of Odd Digits</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Find the Sum of the First and Last Digits]]></title>
            <link>https://python.plainenglish.io/python-program-to-find-the-sum-of-the-first-and-last-digits-70ed2584e285?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/70ed2584e285</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 04:33:03 GMT</pubDate>
            <atom:updated>2026-11-13T04:33:03.708Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, we can find the sum of the first and last digits of a number using arithmetic operators, loops, and conditional statements.</p><blockquote>For example, consider the number 12345:</blockquote><blockquote>First digit = 1</blockquote><blockquote>Last digit = 5</blockquote><blockquote>Sum = 1 + 5 = 6</blockquote><p>In this article, we will learn how to write a Python program to find the sum of the first and last digits of a number using different methods.</p><h3><strong>Python Program to Find the Sum of the First and Last Digits</strong></h3><p>The following program accepts a number from the user and calculates the sum of its first and last digits.</p><h4><strong>Program :</strong></h4><pre>num = int(input(&quot;Enter a number: &quot;))<br>num = abs(num)<br>last_digit = num % 10<br>while num &gt;= 10:<br>num = num // 10<br>first_digit = num<br>total = first_digit + last_digit<br>print(&quot;Sum of first and last digits:&quot;, total)</pre><p><strong>Output :</strong></p><p>Enter a number: 12345</p><p>Sum of first and last digits: 6</p><h3><strong>Different Methods to Find the Sum of the First and Last Digits in Python</strong></h3><p>Python provides several approaches to solve this problem. Let’s explore some common methods.</p><h4><strong>1. Using a While Loop :</strong></h4><p>A while loop can be used to extract the first digit by repeatedly removing the last digit.</p><pre>num = int(input(&quot;Enter a number: &quot;))<br>num = abs(num)<br>last = num % 10<br>while num &gt;= 10:<br>num //= 10<br>first = num<br>print(&quot;Sum:&quot;, first + last)</pre><p><strong>Output:</strong></p><p>Enter a number: 9876</p><p>Sum: 15</p><h4><strong>2. Using String Conversion</strong></h4><p>We can convert the number into a string and access its first and last characters using indexing.</p><pre>num = input(&quot;Enter a number: &quot;)<br>num = num.lstrip(&quot;-&quot;)<br>first = int(num[0])<br>last = int(num[-1])<br>total = first + last<br>print(&quot;Sum of first and last digits:&quot;, total)</pre><p><strong>Output:</strong></p><p>Enter a number: 45678</p><p>Sum of first and last digits: 12</p><h4><strong>3. Using a Function</strong></h4><p>We can create a reusable function to calculate the sum of the first and last digits.</p><pre>def sum_first_last(num):<br>num = abs(num)<br>last = num % 10<br>while num &gt;= 10:<br>num //= 10<br>first = num<br>return first + last<br>result = sum_first_last(12345)<br>print(&quot;Sum:&quot;, result)</pre><p><strong>Output:</strong></p><p>Sum: 6</p><h4><strong>4. Using a For Loop</strong></h4><p>A for loop can be used to find the first and last digits after converting the number into a string.</p><pre>num = input(&quot;Enter a number: &quot;)<br>num = num.lstrip(&quot;-&quot;)<br>first = 0<br>last = 0<br>for i in range(len(num)):<br>if i == 0:<br>first = int(num[i])<br>if i == len(num) - 1:<br>last = int(num[i])<br>print(&quot;Sum:&quot;, first + last)</pre><p><strong>Output:</strong></p><p>Enter a number: 23456</p><p>Sum: 8</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70ed2584e285" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-find-the-sum-of-the-first-and-last-digits-70ed2584e285">Python Program to Find the Sum of the First and Last Digits</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Find the Difference Between Two Numbers]]></title>
            <link>https://python.plainenglish.io/python-program-to-find-the-difference-between-two-numbers-60cbd16a7650?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/60cbd16a7650</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 03:48:49 GMT</pubDate>
            <atom:updated>2026-11-11T03:48:49.729Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, finding the difference between two numbers is one of the simplest arithmetic operations. We can use the subtraction (-) operator to subtract one number from another.</p><p>For example, if the first number is 20 and the second number is 8, the difference is:</p><blockquote>20–8 = 12</blockquote><p>In this article, we will learn how to write a Python program to find the difference between two numbers using different methods.</p><h3><strong>Python Program to Find the Difference Between Two Numbers</strong></h3><p>The following program takes two numbers as input from the user and calculates their difference using the subtraction operator.</p><h4><strong>Program :</strong></h4><pre>num1 = float(input(&quot;Enter the first number: &quot;))<br>num2 = float(input(&quot;Enter the second number: &quot;))<br>difference = num1 - num2<br>print(&quot;Difference:&quot;, difference)</pre><p><strong>Output :</strong></p><p>Enter the first number: 20</p><p>Enter the second number: 8</p><p>Difference: 12.0</p><h3><strong>Different Methods to Find the Difference Between Two Numbers in Python</strong></h3><p>Python provides several ways to calculate the difference between two numbers. Let’s explore some common approaches.</p><h4><strong>1. Using Integer Input :</strong></h4><p>If you want to work with whole numbers, you can use int() instead of float().</p><pre>num1 = int(input(&quot;Enter the first number: &quot;))<br>num2 = int(input(&quot;Enter the second number: &quot;))<br>difference = num1 - num2<br>print(&quot;Difference:&quot;, difference)</pre><p><strong>Output:</strong></p><p>Enter the first number: 50</p><p>Enter the second number: 25</p><p>Difference: 25</p><h4><strong>2. Using Direct Values :</strong></h4><p>You can also assign values directly to variables without asking the user for input.</p><pre>num1 = 100<br>num2 = 40<br>difference = num1 - num2<br>print(&quot;Difference:&quot;, difference)</pre><p><strong>Output:</strong></p><p>Difference: 60</p><h4><strong>3. Using a Function :</strong></h4><p>A function makes the subtraction operation reusable. You can call the same function with different numbers.</p><pre>def find_difference(a, b):<br>return a - b<br>result = find_difference(75, 30)<br>print(&quot;Difference:&quot;, result)</pre><p><strong>Output:</strong></p><p>Difference: 45</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60cbd16a7650" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-find-the-difference-between-two-numbers-60cbd16a7650">Python Program to Find the Difference Between Two Numbers</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Find the First Element of a List]]></title>
            <link>https://python.plainenglish.io/python-program-to-find-the-first-element-of-a-list-2d45db525858?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d45db525858</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 03:43:32 GMT</pubDate>
            <atom:updated>2026-11-11T03:43:32.061Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is a popular programming language known for its simple syntax and readability. It is widely used in web development, data science, artificial intelligence, automation, and software development.</p><p>One of the important data structures in Python is a list. A list is used to store multiple items in a single variable. Lists are ordered, changeable, and allow duplicate values.</p><p>In this tutorial, we will learn how to write a Python program to find the first element of a list.</p><h3><strong>What Is a List in Python?</strong></h3><p>A list is a collection of elements stored in a single variable. Lists are created using square brackets [].</p><h4>For example:</h4><pre>numbers = [10, 20, 30, 40, 50]<br>print(numbers)</pre><p>Output:</p><p>[10, 20, 30, 40, 50]</p><p>In Python, list indexing starts from 0.</p><h3><strong>Python Program to Find the First Element of a List Using Indexing</strong></h3><p>The simplest way to find the first element of a list in Python is by using list indexing.</p><p>We can access the first element by specifying index 0.</p><h4><strong>Python Code :</strong></h4><pre># Python program to find the first element of a list<br>numbers = [10, 20, 30, 40, 50]<br>first_element = numbers[0]<br>print(&quot;The first element of the list is:&quot;, first_element)</pre><p><strong>Output :</strong></p><p>The first element of the list is: 10</p><h3><strong>Python Program to Find the First Element of a List Using a Function</strong></h3><p>We can also define a function to find the first element of a list.</p><p>Functions help us organize code and reuse it whenever needed.</p><h4><strong>Python Code :</strong></h4><pre># Function to find the first element of a list<br>def find_first_element(numbers):<br>if len(numbers) &gt; 0:<br>return numbers[0]<br>else:<br>return None<br>my_list = [10, 20, 30, 40, 50]<br>result = find_first_element(my_list)<br>print(&quot;The first element of the list is:&quot;, result)</pre><p><strong>Output :</strong></p><p>The first element of the list is: 10</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d45db525858" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-find-the-first-element-of-a-list-2d45db525858">Python Program to Find the First Element of a List</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Print the First 10 Multiples of a Number]]></title>
            <link>https://python.plainenglish.io/python-program-to-print-the-first-10-multiples-of-a-number-959ce7d26ffe?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/959ce7d26ffe</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 04:16:07 GMT</pubDate>
            <atom:updated>2026-11-05T04:16:07.688Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is a popular programming language known for its simple syntax and readability. It is widely used in web development, data science, artificial intelligence, automation, and software development.</p><p>One of the basic concepts in Python programming is the use of loops. Loops allow us to execute a block of code repeatedly without writing the same statements multiple times.</p><p>In this tutorial, we will learn how to write a Python program to print the first 10 multiples of a number.</p><h3><strong>What Are Multiples of a Number?</strong></h3><p>Multiples of a number are the values obtained by multiplying that number by positive integers such as 1, 2, 3, 4, and so on.</p><p>For example, the first 10 multiples of 5 are:</p><blockquote>5, 10, 15, 20, 25, 30, 35, 40, 45, 50</blockquote><h3><strong>Python Program to Print the First 10 Multiples of a Number Using a For Loop</strong></h3><p>The for loop is one of the simplest ways to print the first 10 multiples of a number in Python.</p><p>We can use the range() function to generate numbers from 1 to 10 and multiply each number by the given input.</p><h4><strong>Python Code :</strong></h4><pre># Python program to print the first 10 multiples of a number<br>num = int(input(&quot;Enter a number: &quot;))<br>for i in range(1, 11):<br>print(num * i)</pre><p><strong>Output :</strong></p><p>Enter a number: 5</p><p>5</p><p>10</p><p>15</p><p>20</p><p>25</p><p>30</p><p>35</p><p>40</p><p>45</p><p>50</p><h3><strong>Python Program to Print the First 10 Multiples Using a While Loop</strong></h3><p>A while loop executes a block of code as long as a given condition is true.</p><p>We can use a while loop to print the first 10 multiples of a number.</p><h4><strong>Python Code :</strong></h4><pre># Python program to print the first 10 multiples using while loop<br>num = int(input(&quot;Enter a number: &quot;))<br>i = 1<br>while i &lt;= 10:<br>print(num * i)<br>i += 1</pre><p><strong>Output :</strong></p><p>Enter a number: 7</p><p>7</p><p>14</p><p>21</p><p>28</p><p>35</p><p>42</p><p>49</p><p>56</p><p>63</p><p>70</p><h3><strong>Python Program to Print the First 10 Multiples Using a Function</strong></h3><p>We can also create a function to print the first 10 multiples of a number.</p><p>Functions help us organize code and reuse it whenever needed.</p><h4><strong>Python Code :</strong></h4><pre># Function to print the first 10 multiples of a number<br>def print_multiples(num):<br>for i in range(1, 11):<br>print(num * i)<br>number = int(input(&quot;Enter a number: &quot;))<br>print_multiples(number)</pre><p><strong>Output :</strong></p><p>Enter a number: 8</p><p>8</p><p>16</p><p>24</p><p>32</p><p>40</p><p>48</p><p>56</p><p>64</p><p>72</p><p>80</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=959ce7d26ffe" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-print-the-first-10-multiples-of-a-number-959ce7d26ffe">Python Program to Print the First 10 Multiples of a Number</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Program to Print Even Numbers from 1 to 100]]></title>
            <link>https://python.plainenglish.io/python-program-to-print-even-numbers-from-1-to-100-66b9d615ff22?source=rss-08160f2e2e71------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b9d615ff22</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vikas]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 04:09:35 GMT</pubDate>
            <atom:updated>2026-11-05T04:09:35.801Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is a popular programming language known for its simple syntax and readability. It is widely used in web development, data science, artificial intelligence, automation, and software development.</p><p>One of the basic concepts in Python programming is the use of loops and conditional statements. These concepts help us perform repetitive tasks and solve mathematical problems efficiently.</p><p>In this tutorial, we will learn how to write a Python program to print even numbers from 1 to 100.</p><h3><strong>What Are Even Numbers?</strong></h3><p>Even numbers are integers that are divisible by 2 without leaving a remainder.</p><p>Examples of even numbers are:</p><blockquote>2, 4, 6, 8, 10, 12, 14, 16, 18, 20, …</blockquote><p>The modulo (%) operator in Python returns the remainder after division.</p><p>For example:</p><pre>print(10 % 2)</pre><p>Output:</p><p>0</p><p>Since the remainder is 0, 10 is an even number.</p><p>Similarly, a number is even if:</p><p>number % 2 == 0</p><h3><strong>Python Program to Print Even Numbers from 1 to 100 Using a For Loop</strong></h3><p>The for loop is one of the simplest ways to print even numbers from 1 to 100.</p><p>We can use the range() function with a step value of 2 to generate even numbers directly.</p><h4><strong>Python Code :</strong></h4><pre># Python program to print even numbers from 1 to 100<br>for i in range(2, 101, 2):<br>print(i)</pre><p><strong>Output:</strong></p><p>2</p><p>4</p><p>6</p><p>8</p><p>10</p><p>12</p><p>14</p><p>16</p><p>18</p><p>20</p><p>22</p><p>24</p><p>26</p><p>28</p><p>30</p><p>32</p><p>34</p><p>36</p><p>38</p><p>40</p><p>42</p><p>44</p><p>46</p><p>48</p><p>50</p><p>52</p><p>54</p><p>56</p><p>58</p><p>60</p><p>62</p><p>64</p><p>66</p><p>68</p><p>70</p><p>72</p><p>74</p><p>76</p><p>78</p><p>80</p><p>82</p><p>84</p><p>86</p><p>88</p><p>90</p><p>92</p><p>94</p><p>96</p><p>98</p><p>100</p><h3><strong>Python Program to Print Even Numbers from 1 to 100 Using a While Loop</strong></h3><p>A while loop executes a block of code as long as a given condition is true.</p><p>We can use a while loop to print even numbers from 1 to 100.</p><h4><strong>Python Code :</strong></h4><pre># Python program to print even numbers using while loop<br>i = 2<br>while i &lt;= 100:<br>print(i)<br>i += 2</pre><p><strong>Output :</strong></p><p>2</p><p>4</p><p>6</p><p>8</p><p>10</p><p>12</p><p>14</p><p>16</p><p>18</p><p>20</p><p>…</p><p>96</p><p>98</p><p>100</p><h3><strong>Python Program to Print Even Numbers from 1 to 100 Using the Modulo Operator</strong></h3><p>We can also print even numbers by checking whether each number is divisible by 2.</p><p>In this approach, we use the modulo (%) operator and an if statement.</p><h4><strong>Python Code :</strong></h4><pre># Python program to print even numbers using modulo operator<br>for i in range(1, 101):<br>if i % 2 == 0:<br>print(i)</pre><p><strong>Output :</strong></p><p>2</p><p>4</p><p>6</p><p>8</p><p>10</p><p>12</p><p>14</p><p>16</p><p>18</p><p>20</p><p>…</p><p>96</p><p>98</p><p>100</p><h3><strong>Python Program to Print Even Numbers from 1 to 100 Using a Function</strong></h3><p>We can also create a function to print even numbers from 1 to 100.</p><p>Functions help us organize code and reuse it whenever needed.</p><h4><strong>Python Code :</strong></h4><pre># Function to print even numbers from 1 to 100<br>def print_even_numbers():<br>for i in range(2, 101, 2):<br>print(i)<br>print_even_numbers()</pre><p><strong>Output :</strong></p><p>2</p><p>4</p><p>6</p><p>8</p><p>10</p><p>…</p><p>96</p><p>98</p><p>100</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b9d615ff22" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/python-program-to-print-even-numbers-from-1-to-100-66b9d615ff22">Python Program to Print Even Numbers from 1 to 100</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>