<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Divya Dixit</title>
    <description>The latest articles on DEV Community by Divya Dixit (@div1904).</description>
    <link>https://dev.to/div1904</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%2F2899440%2F5b62e236-685e-40b3-a619-c484070804a0.jpg</url>
      <title>DEV Community: Divya Dixit</title>
      <link>https://dev.to/div1904</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/div1904"/>
    <language>en</language>
    <item>
      <title>Understanding While Loops in Python</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Sun, 09 Mar 2025 14:56:36 +0000</pubDate>
      <link>https://dev.to/div1904/understanding-while-loops-in-python-2d3o</link>
      <guid>https://dev.to/div1904/understanding-while-loops-in-python-2d3o</guid>
      <description>&lt;p&gt;In the last post, we discussed &lt;code&gt;if&lt;/code&gt; statements, which help us skip a part of the code based on a condition. But what if we want to repeat a block of code multiple times? Instead of writing the same statement repeatedly, we use &lt;strong&gt;looping statements&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a While Loop?
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;while&lt;/code&gt; loop in Python is used to execute a block of code &lt;strong&gt;repeatedly&lt;/strong&gt; as long as a given condition is &lt;code&gt;True&lt;/code&gt;. Once the condition becomes &lt;code&gt;False&lt;/code&gt;, the loop terminates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax of While Loop
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Code to execute
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A while loop consists of three main parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialization&lt;/strong&gt;: Define where the loop starts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition&lt;/strong&gt;: Set a condition that controls the loop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increment/Decrement&lt;/strong&gt;: Change the variable to eventually break the loop.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Example: Printing Numbers from 1 to 10
&lt;/h3&gt;

&lt;p&gt;Instead of writing 10 &lt;code&gt;print&lt;/code&gt; statements, we can use a &lt;code&gt;while&lt;/code&gt; loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Initialization
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Condition
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Increment
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example: Printing Numbers from 10 to 1
&lt;/h3&gt;

&lt;p&gt;We can also print numbers in reverse order by decrementing the value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  &lt;span class="c1"&gt;# Initialization
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Condition
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Decrement
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Infinite Loops
&lt;/h2&gt;

&lt;p&gt;If the loop condition never becomes &lt;code&gt;False&lt;/code&gt;, it runs indefinitely. Be cautious! For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Always True condition
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid this, always ensure the condition eventually turns &lt;code&gt;False&lt;/code&gt; by updating the variable inside the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using While Loops with Break and Continue
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;break&lt;/code&gt;: Terminates the loop immediately.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;  &lt;span class="c1"&gt;# Stops the loop when i is 5
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;continue&lt;/code&gt;: Skips the current iteration and moves to the next.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# Skips printing 5
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Use While Loops?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When the number of iterations is &lt;strong&gt;not fixed&lt;/strong&gt; (e.g., waiting for user input, processing data until a condition is met).&lt;/li&gt;
&lt;li&gt;When continuously monitoring something (e.g., a sensor reading, network connection).&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; loop is an essential tool in Python for handling repetitive tasks efficiently. By understanding its components—&lt;strong&gt;initialization, condition, and increment/decrement&lt;/strong&gt;—you can write efficient looping constructs in your programs. Experiment with different conditions and use cases to get comfortable with &lt;code&gt;while&lt;/code&gt; loops!&lt;/p&gt;

&lt;p&gt;🚀 Stay tuned for more Python basics!&lt;/p&gt;

</description>
      <category>coding</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python If-Else Statement Explained (With Examples)</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Tue, 04 Mar 2025 12:23:09 +0000</pubDate>
      <link>https://dev.to/div1904/python-if-else-statement-explained-with-examples-52mo</link>
      <guid>https://dev.to/div1904/python-if-else-statement-explained-with-examples-52mo</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In Python, decision-making is achieved using conditional statements. These statements allow us to control the flow of a program by executing certain blocks of code based on conditions. The key decision-making statements in Python are:&lt;/p&gt;

&lt;p&gt;if&lt;/p&gt;

&lt;p&gt;if-else&lt;/p&gt;

&lt;p&gt;if-elif-else&lt;/p&gt;

&lt;p&gt;These statements use relational operators (&amp;gt;, &amp;lt;, ==, etc.) to evaluate conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use If-Else?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, Python executes code line by line in a sequential manner. However, sometimes we need to skip or alter the execution flow based on specific conditions. To achieve this, we use if-else statements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How If-Else Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An if statement evaluates a condition. If the condition is True, the indented block of code runs. If it is False, the block is skipped, and if an else block is provided, it executes instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example: Checking Voting Eligibility
&lt;/h2&gt;

&lt;p&gt;Let's check if a person is eligible to vote (age 18 or above):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age = int(input("Enter your age: "))
if age &amp;gt;= 18:
    print("You are eligible to vote.")
else:
    print("You are not eligible to vote.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Syntax Breakdown&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Colon (:)&lt;/strong&gt; after if and else indicates the start of an indented block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Indentation&lt;/strong&gt; (spaces or a tab) defines which statements belong to if or else.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;else&lt;/strong&gt; block executes only if the if condition is False.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using elif for Multiple Conditions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, we need to check multiple conditions. This is where elif (short for else if) comes in.&lt;/p&gt;

&lt;p&gt;For example, let's categorize a person based on age:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age = int(input("Enter your age: "))
if age &amp;lt; 16:
    print("You are a child.")
elif age &amp;lt; 18:
    print("You are a teenager.")
elif age &amp;gt; 50:
    print("You are old.")
else:
    print("You are an adult.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;p&gt;If the first condition (age &amp;lt; 16) is True, the program executes that block and skips the rest.&lt;/p&gt;

&lt;p&gt;If False, the next condition (age &amp;lt; 18) is checked.&lt;/p&gt;

&lt;p&gt;If no conditions are True, the else block runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Practical Examples
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Checking Even or Odd Number&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A number is even if it is divisible by 2 (i.e., remainder 0 when divided by 2), otherwise, it is odd.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = int(input("Enter a number: "))
if num % 2 == 0:
    print("The number is even.")
else:
    print("The number is odd.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Checking Positive, Negative, or Zero&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = int(input("Enter a number: "))
if num &amp;gt; 0:
    print("The number is positive.")
elif num &amp;lt; 0:
    print("The number is negative.")
else:
    print("The number is zero.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best Practices for Writing If-Else Statements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always use indentation (4 spaces per level) to maintain readability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. Use elif instead of multiple if statements when checking multiple conditions. &lt;/li&gt;
&lt;li&gt;3. Keep conditions simple and readable&lt;/li&gt;
&lt;li&gt;5. Use parentheses if conditions are complex (e.g., (x &amp;gt; 0) and (y &amp;lt; 100)).&lt;/li&gt;
&lt;li&gt;7. Use meaningful variable names.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The if statement evaluates a condition.&lt;/li&gt;
&lt;li&gt;The else statement provides an alternative execution path.&lt;/li&gt;
&lt;li&gt;The elif statement allows multiple conditions to be checked sequentially.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By mastering if-else, you can write dynamic and interactive Python programs. Start experimenting with different conditions and enhance your coding skills!&lt;/p&gt;

</description>
      <category>python</category>
      <category>coding</category>
      <category>beginners</category>
      <category>java</category>
    </item>
    <item>
      <title>🚀 Mastering Python Operators: Comparison, Bitwise &amp; Assignment</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Sun, 02 Mar 2025 16:26:54 +0000</pubDate>
      <link>https://dev.to/div1904/mastering-python-operators-comparison-bitwise-assignment-45m</link>
      <guid>https://dev.to/div1904/mastering-python-operators-comparison-bitwise-assignment-45m</guid>
      <description>&lt;p&gt;In our previous posts, we covered logical and arithmetic operators in Python. Now, let's take a deep dive into comparison (relational) operators, followed by bitwise and assignment operators, which play a crucial role in data processing and optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 Understanding Comparison (Relational) Operators
&lt;/h2&gt;

&lt;p&gt;As the name suggests, comparison operators are used to compare two values and determine relationships like greater than, lesser than, or equality. They are fundamental in decision-making processes in programming.&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;Examples of Comparison Operators in Action&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;print(10 &amp;gt; 3)   # True (10 is greater than 3)
print(10 &amp;gt;= 10) # True (10 is equal to 10)
print(5 &amp;lt; 8)    # True (5 is less than 8)
print(7 &amp;lt;= 7)   # True (7 is equal to 7)
print(4 == 4)   # True (Both values are equal)
print(6 != 9)   # True (6 is not equal to 9)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  List of Python Comparison Operators
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Greater than    10 &amp;gt; 3  True&lt;br&gt;
&amp;lt;   Less than   5 &amp;lt; 8   True&lt;br&gt;
=  Greater than or equal to    10 &amp;gt;= 10    True&lt;br&gt;
&amp;lt;=  Less than or equal to   7 &amp;lt;= 7  True&lt;br&gt;
==  Equal to    4 == 4  True&lt;br&gt;
!=  Not equal to    6 != 9  True&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🔥 &lt;strong&gt;Where Are Comparison Operators Used?&lt;/strong&gt;&lt;br&gt;
Comparison operators are commonly used in conditional statements, loops, and filtering data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age = 18
if age &amp;gt;= 18:
    print("You are eligible to vote!")
else:
    print("You are not eligible to vote.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bitwise Operators in Python
&lt;/h2&gt;

&lt;p&gt;Bitwise operators allow us to perform operations at the binary level (bit by bit). These operators are commonly used in low-level programming, cryptography, and optimizing algorithms.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Examples of Bitwise Operators&lt;/strong&gt;&lt;br&gt;
Let’s take a simple example using 5 and 3:&lt;/p&gt;

&lt;p&gt;a = 5  # Binary:  0101&lt;br&gt;
b = 3  # Binary:  0011&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(a &amp;amp; b)  # AND  -&amp;gt; 1  (Binary: 0001)
print(a | b)  # OR   -&amp;gt; 7  (Binary: 0111)
print(a ^ b)  # XOR  -&amp;gt; 6  (Binary: 0110)
print(~a)     # NOT  -&amp;gt; -6 (Binary: Inverts bits)
print(a &amp;lt;&amp;lt; 1) # Left Shift  -&amp;gt; 10 (Binary: 1010)
print(b &amp;gt;&amp;gt; 1) # Right Shift -&amp;gt; 1  (Binary: 0001)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📊** List of Bitwise Operators**&lt;br&gt;
 (a=5, b=3) &lt;br&gt;
&amp;amp;   Bitwise AND 5 &amp;amp; 3   0001    1&lt;br&gt;
&lt;code&gt;&lt;/code&gt;   Bitwise OR  &lt;code&gt;5 3&lt;/code&gt;&lt;br&gt;
^   Bitwise XOR 5 ^ 3   0110    6&lt;br&gt;
~   Bitwise NOT ~5  -0110   -6&lt;br&gt;
&amp;lt;&amp;lt;  Left Shift  5 &amp;lt;&amp;lt; 1  1010    10&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Right Shift 3 &amp;gt;&amp;gt; 1  0001    1&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;🔥 &lt;strong&gt;Where Are Bitwise Operators Used?&lt;/strong&gt;&lt;br&gt;
Cryptography 🛡️ (e.g., encryption algorithms)&lt;br&gt;
Image Processing 🖼️ (pixel manipulation)&lt;br&gt;
Low-level System Operations 🖥️ (memory optimization)&lt;br&gt;
Fast Computations ⚡ (bitwise tricks can replace arithmetic operations)&lt;/p&gt;
&lt;h2&gt;
  
  
  Assignment Operators in Python
&lt;/h2&gt;

&lt;p&gt;Assignment operators modify variables efficiently by performing operations and storing the result in the same variable.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Examples of Assignment Operators&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;x = 10  # Simple assignment
x += 5  # Equivalent to x = x + 5
x -= 2  # Equivalent to x = x - 2
x *= 3  # Equivalent to x = x * 3
x /= 2  # Equivalent to x = x / 2
x %= 3  # Equivalent to x = x % 3
x //= 2 # Equivalent to x = x // 2
x **= 2 # Equivalent to x = x ** 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📊 &lt;strong&gt;List of Assignment Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=   Assign value    x = 10  10&lt;br&gt;
+=  Add and assign  x += 5  15&lt;br&gt;
-=  Subtract and assign x -= 2  8&lt;br&gt;
&lt;em&gt;=  Multiply and assign x *= 3  30&lt;br&gt;
/=  Divide and assign   x /= 2  5.0&lt;br&gt;
%=  Modulus and assign  x %= 3  2&lt;br&gt;
//= Floor divide and assign x //= 2 5&lt;br&gt;
*&lt;/em&gt;= Exponentiate and assign x **= 2 100&lt;/p&gt;

&lt;p&gt;🔥 &lt;strong&gt;Where Are Assignment Operators Used?&lt;/strong&gt;&lt;br&gt;
Mathematical Calculations (shortcuts in algebraic operations)&lt;br&gt;
Updating Variables in Loops (x += 1 for counter increments)&lt;br&gt;
Game Development (modifying game scores, physics updates)&lt;br&gt;
Data Processing (efficient calculations in big data applications)&lt;/p&gt;

&lt;p&gt;🎯 Conclusion&lt;br&gt;
Comparison operators are essential for decision-making in Python.&lt;br&gt;
Bitwise operators allow for efficient binary-level computations.&lt;br&gt;
Assignment operators optimize variable manipulation for better performance.&lt;br&gt;
These operators are powerful tools for writing efficient Python programs. Stay tuned for our next post, where we’ll explore identity and membership operators in Python! 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Operators: Arithmetic and Logical Operators Explained</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Sat, 01 Mar 2025 11:00:58 +0000</pubDate>
      <link>https://dev.to/div1904/python-operators-arithmetic-and-logical-operators-explained-3g4e</link>
      <guid>https://dev.to/div1904/python-operators-arithmetic-and-logical-operators-explained-3g4e</guid>
      <description>&lt;p&gt;An operator is something that performs an operation on values. Just like in mathematics, where we use + for addition, Python provides various types of operators, including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Arithmetic Operators&lt;/li&gt;
&lt;li&gt;Relational Operators&lt;/li&gt;
&lt;li&gt;Conditional Operators&lt;/li&gt;
&lt;li&gt;Ternary Operators&lt;/li&gt;
&lt;li&gt;Logical Operators&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this first part, we will focus on Arithmetic and Logical operators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arithmetic Operators in Python
&lt;/h2&gt;

&lt;p&gt;Arithmetic operators are used to perform basic mathematical operations. Here’s a list of them:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;+&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adds two numbers (e.g., 5 + 3 = 8)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subtraction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;-&lt;/p&gt;

&lt;p&gt;Subtracts the right operand from the left operand (e.g., 10 - 4 = 6)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiplication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;*&lt;/p&gt;

&lt;p&gt;Multiplies two numbers (e.g., 7 * 2 = 14)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Division&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;/&lt;/p&gt;

&lt;p&gt;Divides the left operand by the right operand (e.g., 10 / 2 = 5.0)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Floor Division&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;//&lt;/p&gt;

&lt;p&gt;Returns the quotient, discarding the decimal part (e.g., 12 // 5 = 2)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modulus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;%&lt;/p&gt;

&lt;p&gt;Returns the remainder (e.g., 12 % 5 = 2)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exponentiation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Raises one number to the power of another (e.g., 2 ** 3 = 8)&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Floor Division and Modulus
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Floor Division (//)&lt;/strong&gt;: This operator returns the quotient but removes the decimal part. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(12 // 5)  # Output: 2

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

&lt;/div&gt;



&lt;p&gt;Here, 12 / 5 would normally give 2.4, but // only takes 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modulus (%)&lt;/strong&gt;: This operator returns the remainder after division. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(12 % 5)  # Output: 2

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

&lt;/div&gt;



&lt;p&gt;Since 12 divided by 5 gives 2 remainder 2, % returns 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exponentiation (&lt;/strong&gt;)**: This operator raises a number to a power. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(2 ** 2)  # Output: 4
print(3 ** 2)  # Output: 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Logical Operators in Python
&lt;/h2&gt;

&lt;p&gt;Logical operators include and, or, and not. They operate on conditions, not numbers. For example, if we want to check whether 4 &amp;gt; 3 and 4 &amp;gt; 1 simultaneously, we use logical operators. These conditions evaluate to True or False.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AND (and)&lt;/strong&gt;: Returns True only if both conditions are True. If any condition is False, the result will be False.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OR (or)&lt;/strong&gt;: Returns True if at least one condition is True. The result is False only when both conditions are False.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOT (not)&lt;/strong&gt;: This operator negates the result. If a condition is True, not makes it False, and vice versa.&lt;/p&gt;

&lt;p&gt;In computer language, we often denote True with 1 and False with 0.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;AND behaves like multiplication:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
1 and 1 → 1&lt;/p&gt;

&lt;p&gt;1 and 0 → 0&lt;/p&gt;

&lt;p&gt;0 and 1 → 0&lt;/p&gt;

&lt;p&gt;0 and 0 → 0&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;OR is like choosing the larger value:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
1 or 1 → 1&lt;/p&gt;

&lt;p&gt;1 or 0 → 1&lt;/p&gt;

&lt;p&gt;0 or 1 → 1&lt;/p&gt;

&lt;p&gt;0 or 0 → 0&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;NOT reverses the condition:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
not True → False&lt;/p&gt;

&lt;p&gt;not False → True&lt;/p&gt;

&lt;p&gt;Example Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 4
y = 3

# AND operator
print(x &amp;gt; 3 and x &amp;gt; 1)  # Output: True

# OR operator
print(x &amp;gt; 10 or x &amp;gt; 3)  # Output: True

# NOT operator
print(not (x &amp;gt; 3))  # Output: False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This concludes our first part on Arithmetic and Logical Operators. In the next part, we will explore Relational, Conditional, and Ternary Operators in Python. Stay tuned!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Python Output Formatting: Aligning, Padding &amp; More</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Fri, 28 Feb 2025 13:50:52 +0000</pubDate>
      <link>https://dev.to/div1904/mastering-python-output-formatting-aligning-padding-more-4han</link>
      <guid>https://dev.to/div1904/mastering-python-output-formatting-aligning-padding-more-4han</guid>
      <description>&lt;p&gt;In our previous post, we explored Python output using the print() function. However, Python provides powerful formatting options to enhance how output is presented. From text alignment and zero-padding to variable ordering, mastering these techniques will improve the readability and structure of your Python programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔹 1. Zero-Padding and Alignment in Python Output
&lt;/h2&gt;

&lt;p&gt;Sometimes, we need numbers to maintain a consistent width, such as displaying 007 instead of 7. Python provides several padding techniques for such formatting.&lt;/p&gt;

&lt;p&gt;🟢 Left Padding (Zero-Fill)&lt;/p&gt;

&lt;p&gt;Ensures numbers have a fixed number of digits by padding with zeros:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;number = 7
print("{:03d}".format(number))  # Output: 007
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🟢 Right Padding (Text Alignment)&lt;/p&gt;

&lt;p&gt;Aligns text to the left and fills extra spaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text = "Hi"
print("{:&amp;lt;5}".format(text))  # Output: 'Hi   '
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🟢 Center Alignment&lt;/p&gt;

&lt;p&gt;Places text in the middle of a fixed-width space:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("{:^10}".format("Hello"))  # Output: '  Hello   '

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔹 2. Using the .format() Method
&lt;/h2&gt;

&lt;p&gt;One of Python’s most flexible ways to format output is the .format() method. Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Brian"
age = 23
print("My name is {} and my age is {}.".format(name, age))
&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;My name is Brian and my age is 23.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Changing Placeholder Order&lt;/p&gt;

&lt;p&gt;We can rearrange placeholders to swap variable positions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("My name is {1} and my age is {0}.".format(age, name))

&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;My name is Brian and my age is 23.

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔹 3. The Power of F-Strings (Python 3.6+)
&lt;/h2&gt;

&lt;p&gt;F-strings provide a shorter and more readable way to format output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(f"My name is {name} and my age is {age}.")

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

&lt;/div&gt;



&lt;p&gt;🔹 Why use F-Strings?&lt;br&gt;
✅ Faster execution compared to .format() and % formatting.✅ More readable and cleaner syntax.&lt;/p&gt;
&lt;h2&gt;
  
  
  🔹 4. Using % Formatting (Old Method)
&lt;/h2&gt;

&lt;p&gt;Before .format() and f-strings, Python used % formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Brian"
age = 23
print("My name is %s and my age is %d." % (name, age))

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

&lt;/div&gt;



&lt;p&gt;🔹 Common % Specifiers:&lt;/p&gt;

&lt;p&gt;%s → String placeholder&lt;/p&gt;

&lt;p&gt;%d → Integer placeholder&lt;/p&gt;

&lt;p&gt;%f → Floating-point (default 6 decimal places)&lt;/p&gt;

&lt;p&gt;Example with floating-point formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;price = 45.6789
print("The price is %.2f" % price)  # Output: The price is 45.68
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔹 5. Additional Print Formatting Techniques
&lt;/h2&gt;

&lt;p&gt;✅ Using sep for Custom Separators&lt;/p&gt;

&lt;p&gt;The sep argument customizes how values are separated in output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Python", "is", "awesome", sep=" - ")

&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;Python - is - awesome

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

&lt;/div&gt;



&lt;p&gt;✅ Controlling Line Breaks in print()&lt;/p&gt;

&lt;p&gt;By default, print() moves to a new line after execution:&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("World")

&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
World
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To prevent a new line and print on the same line, use end="":&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", end="")
print("World")
&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;HelloWorld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add a space between words:&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", end=" ")
print("World")
&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 World

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  🤔 Why Use These Formatting Methods?
&lt;/h2&gt;

&lt;p&gt;✔️ Improved Readability – Produces clean and structured output.&lt;br&gt;
✔️ Custom Order Control – Dynamically arrange variables in text.&lt;br&gt;
✔️ Zero-Padding &amp;amp; Alignment – Maintain consistent number formats.&lt;br&gt;
✔️ Multiple Formatting Choices – Use .format(), f-strings, or % formatting.&lt;br&gt;
✔️ Better Debugging – print() options help troubleshoot errors efficiently.&lt;/p&gt;

&lt;p&gt;Mastering these techniques will make your Python programs more professional and user-friendly. Try experimenting with them in your next project! 🚀&lt;/p&gt;

&lt;p&gt;💬 What’s your favorite way to format output in Python? Drop a comment below! 👇&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python Data Types – A Beginner’s Guide</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Thu, 27 Feb 2025 15:31:46 +0000</pubDate>
      <link>https://dev.to/div1904/python-data-types-a-beginners-guide-18me</link>
      <guid>https://dev.to/div1904/python-data-types-a-beginners-guide-18me</guid>
      <description>&lt;p&gt;In our previous discussion, we explored variables—how they store different types of values in Python. Now, let's dive into data types, which define the kind of data stored in a variable.&lt;/p&gt;

&lt;p&gt;Unlike languages such as Java, C, or C++, where you must explicitly declare a variable’s type, Python handles data types dynamically. This means you can directly assign a value to a variable without specifying its type.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Data Types?
&lt;/h2&gt;

&lt;p&gt;A data type not only defines the type of data stored in a variable but also determines the amount of memory allocated for that variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Data Types in Python
&lt;/h2&gt;

&lt;p&gt;Python provides several built-in data types:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integer (int)&lt;/strong&gt; – Whole numbers, both positive and negative.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num1 = 23  
num2 = -232
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Floating-point (float) *&lt;/em&gt;– Numbers with decimals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num3 = 23.232  
num4 = -23.232  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String (str)&lt;/strong&gt; – Text enclosed in single or double quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Brian"  
blood_group = 'B'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Character (char)&lt;/strong&gt; – Python doesn’t have a separate char type like C or Java. Instead, a single-character string (e.g., 'A', 'B') is still a string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boolean (bool)&lt;/strong&gt; – Represents True or False, often used in conditions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;is_greater = 10 &amp;gt; 3  # True  
is_adult = age &amp;gt;= 18  # True 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Complex Numbers (complex)
&lt;/h2&gt;

&lt;p&gt;Python has a built-in complex type, which is not commonly found in some languages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = 3 + 4j  # Complex number
print(type(num))  # Output: &amp;lt;class 'complex'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Checking Data Types and Memory Usage
&lt;/h2&gt;

&lt;p&gt;Python provides the** type()** function to check the type of any variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(type(232))       # Output: &amp;lt;class 'int'&amp;gt;  
print(type(23.232))    # Output: &amp;lt;class 'float'&amp;gt;  
print(type("Brian"))   # Output: &amp;lt;class 'str'&amp;gt;  
print(type(True))      # Output: &amp;lt;class 'bool'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check the &lt;strong&gt;memory size&lt;/strong&gt; of a variable, use &lt;strong&gt;sys.getsizeof():&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 sys  
print(sys.getsizeof(232))       # Output: Memory size of int  
print(sys.getsizeof(23.232))    # Output: Memory size of float  
print(sys.getsizeof("Brian"))   # Output: Memory size of string 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Memory Usage of Data Types&lt;/p&gt;

&lt;p&gt;Different data types occupy different amounts of memory in Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Observations:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Integers (int)&lt;/strong&gt; – Generally take 28 bytes, but the size can increase with larger numbers.&lt;br&gt;
&lt;strong&gt;Floating-point numbers (float)&lt;/strong&gt; – Usually 24 bytes, independent of the value.&lt;br&gt;
&lt;strong&gt;Strings (str)&lt;/strong&gt; – Memory depends on the length of the string. Each character takes extra space.&lt;br&gt;
*&lt;em&gt;Boolean (bool) *&lt;/em&gt;– Takes 28 bytes, same as an integer.&lt;/p&gt;

&lt;p&gt;Note: Unlike C or Java, where int and float have fixed sizes (e.g., 4 bytes, 8 bytes), Python’s data types are dynamically sized. The actual memory usage can vary depending on the system and Python implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways:
&lt;/h2&gt;

&lt;p&gt;✔ Data types define both the type and memory usage of variables.&lt;br&gt;
✔ Strings generally require more memory than integers or booleans.&lt;br&gt;
✔ Use &lt;strong&gt;type()&lt;/strong&gt; to check the data type and &lt;strong&gt;sys.getsizeof()&lt;/strong&gt; to check memory allocation.&lt;br&gt;
✔ Python dynamically assigns types without explicit declarations.&lt;/p&gt;

&lt;p&gt;This flexibility makes Python beginner-friendly while keeping it powerful for complex applications. 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🚀 Understanding Output in Java</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Thu, 27 Feb 2025 03:29:47 +0000</pubDate>
      <link>https://dev.to/div1904/understanding-output-in-java-57g7</link>
      <guid>https://dev.to/div1904/understanding-output-in-java-57g7</guid>
      <description>&lt;p&gt;in the previous post we've covered the basic syntax of java. Now we will see how to get an output from java programming.&lt;/p&gt;

&lt;h1&gt;
  
  
  🚀 Understanding Output in Java
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What is Output?
&lt;/h2&gt;

&lt;p&gt;Output refers to any result displayed on the screen or provided by the computer after performing a task or operation.&lt;/p&gt;

&lt;p&gt;For example, if we tell a computer to add two numbers (23 and 24), it will process the operation and return a result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Output:&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;47
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This result (&lt;code&gt;47&lt;/code&gt;) is called &lt;strong&gt;output&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Input?
&lt;/h2&gt;

&lt;p&gt;The data provided to the computer is called &lt;strong&gt;input&lt;/strong&gt;. In the above example, &lt;code&gt;23&lt;/code&gt; and &lt;code&gt;24&lt;/code&gt; are inputs, and &lt;code&gt;47&lt;/code&gt; is the output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding System.out.println() Breakdown
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;System.out.println()&lt;/code&gt; is a built-in Java method used to print output to the console. Let's break it down:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System:&lt;/strong&gt; This is a built-in class in Java that provides access to system-related functionalities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;out:&lt;/strong&gt; This is a static member of the System class that represents the standard output stream (console output).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;println()&lt;/strong&gt;: This is a method of PrintStream (the type of out) that prints the provided argument and moves the cursor to the next line.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔹 Printing Output in Java
&lt;/h2&gt;

&lt;p&gt;Unlike Python, Java requires a structured syntax for printing output. Java uses the &lt;code&gt;System.out.println()&lt;/code&gt; method to display output on the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Syntax of &lt;code&gt;System.out.println()&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;strong&gt;arguments&lt;/strong&gt; refer to the values we want to print.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Example 1: Printing a Word or Sentence
&lt;/h3&gt;

&lt;p&gt;To print a word or sentence, we enclose it inside double quotes (&lt;code&gt;""&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Output:&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;Hello, World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Whatever is inside double quotes is printed &lt;strong&gt;exactly&lt;/strong&gt; as it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Example 2: Printing a Mathematical Calculation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Output:&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;57
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java performs the calculation and prints the result.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Example 3: Printing a Number as Text
&lt;/h3&gt;

&lt;p&gt;If we write numbers inside double quotes, Java will treat them as &lt;strong&gt;text (String)&lt;/strong&gt;, not numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"23 + 34"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Output:&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;23 + 34
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Java &lt;strong&gt;does not&lt;/strong&gt; calculate it because it's inside double quotes.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Example 4: What Happens If We Add a Number and a String?
&lt;/h3&gt;

&lt;p&gt;If we try to add a number and a string, Java will &lt;strong&gt;concatenate&lt;/strong&gt; (join) them instead of performing arithmetic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"34"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Output:&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;2334
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚨 &lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;23&lt;/code&gt; is an integer (number).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"34"&lt;/code&gt; is a string (text).&lt;/li&gt;
&lt;li&gt;Java &lt;strong&gt;joins them as text&lt;/strong&gt;, not as numbers.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;✔ &lt;strong&gt;Output&lt;/strong&gt; is what the computer returns after performing an operation.&lt;br&gt;
✔ &lt;strong&gt;Input&lt;/strong&gt; is the data given to the computer.&lt;br&gt;
✔ Java uses &lt;code&gt;System.out.println()&lt;/code&gt; to display output.&lt;br&gt;
✔ &lt;strong&gt;Text&lt;/strong&gt; must be enclosed inside double quotes (&lt;code&gt;"text"&lt;/code&gt;).&lt;br&gt;
✔ If a &lt;strong&gt;number&lt;/strong&gt; is inside quotes, it is treated as &lt;strong&gt;text&lt;/strong&gt;.&lt;br&gt;
✔ Adding a number and a string &lt;strong&gt;concatenates&lt;/strong&gt; them.&lt;br&gt;
✔ To perform &lt;strong&gt;addition&lt;/strong&gt;, convert the string to an integer using &lt;code&gt;Integer.parseInt()&lt;/code&gt;.&lt;br&gt;
✔ To keep them as text, convert the number into a string using &lt;code&gt;String.valueOf()&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Want to Learn More?
&lt;/h2&gt;

&lt;p&gt;Follow me for more &lt;strong&gt;Java programming tutorials&lt;/strong&gt;! 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  Java #Programming #Coding #100DaysOfCode #DevCommunity
&lt;/h1&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
    <item>
      <title>🚀 Java Basic Syntax with Real-World Analogies</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Wed, 26 Feb 2025 19:52:36 +0000</pubDate>
      <link>https://dev.to/div1904/java-basic-syntax-with-real-world-analogies-53g2</link>
      <guid>https://dev.to/div1904/java-basic-syntax-with-real-world-analogies-53g2</guid>
      <description>&lt;p&gt;Java is one of the most popular programming languages, but for beginners, its syntax might seem a bit tricky at first. Don't worry! In this post, we'll break down Java's basic syntax using real-world analogies to make it easier to understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏆 The Java Starter Code
&lt;/h2&gt;

&lt;p&gt;Every Java program starts with a class definition and a main method. Here's a simple Java program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down step by step. 👇&lt;/p&gt;

&lt;h2&gt;
  
  
  1️⃣ public – Like a Public Park 🌳
&lt;/h2&gt;

&lt;p&gt;The keyword public means anyone can access it from anywhere.&lt;/p&gt;

&lt;p&gt;🎯 Analogy: Think of a public park—anyone can enter and use it freely.&lt;/p&gt;

&lt;p&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;public class Hello {
    // This class is accessible to everyone
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, Hello is a class, and since it's public, it can be used in other parts of the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  2️⃣ class – Like a School Class 🏫
&lt;/h2&gt;

&lt;p&gt;Java is an object-oriented programming (OOP) language, which means everything is based on classes and objects.&lt;/p&gt;

&lt;p&gt;🎯 Analogy: A school class (e.g., "10th Grade") is like a Java class.&lt;br&gt;
Students in the class are objects of that class.&lt;/p&gt;

&lt;p&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;public class Hello {
    // Class definition
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, Hello is the class name, just like the name of a school class.&lt;/p&gt;

&lt;h2&gt;
  
  
  3️⃣ static void main – Like Your House’s Entry Door 🚪
&lt;/h2&gt;

&lt;p&gt;Java starts execution from the main method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void main(String[] args) {
    // Code execution starts here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🎯 Analogy:
&lt;/h2&gt;

&lt;p&gt;main is the entry point, just like the main door of your house—everyone must enter through it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;void&lt;/strong&gt; means this method does not return anything. It’s like a teacher giving a lecture without expecting an answer back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;static&lt;/strong&gt; means the method belongs to the class itself, not an individual object. Think of it like school rules—they apply to the whole class, not just one student.&lt;/p&gt;

&lt;h2&gt;
  
  
  4️⃣ System.out.println()
&lt;/h2&gt;

&lt;p&gt;– Like Speaking Out Loud 🗣️&lt;/p&gt;

&lt;h2&gt;
  
  
  System.out.println()
&lt;/h2&gt;

&lt;p&gt;method prints output to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  6️⃣ Semicolon (;) – Like a Full Stop (.) in English 📖
&lt;/h2&gt;

&lt;p&gt;In Java, every statement must end with a semicolon (;).&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Analogy:
&lt;/h2&gt;

&lt;p&gt;Think of a semicolon (;) like a full stop (.) in English.&lt;/p&gt;

&lt;p&gt;In English, a full stop marks the end of a sentence.&lt;br&gt;
In Java, a semicolon marks the end of a statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("Hello, Java!");  
int x = 10;  
x = x + 5; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, each Java statement ends with ;, just like sentences in English end with a full stop (.).&lt;/p&gt;

&lt;p&gt;🚨 Example (Incorrect Usage – Missing ;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("Hello, Java!") // ❌ ERROR! Missing semicolon
int x = 10 // ❌ ERROR! Missing semicolon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  💡 Why does this give an error?
&lt;/h2&gt;

&lt;p&gt;Java expects a semicolon to know where one statement ends and the next begins.&lt;br&gt;
Without a semicolon, Java gets confused—just like a sentence without a full stop can be confusing.&lt;/p&gt;
&lt;h2&gt;
  
  
  7️⃣ String[] args – Like a List of Instructions 📜
&lt;/h2&gt;

&lt;p&gt;In the main method, you might have noticed this strange-looking String[] args:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void main(String[] args) {
    System.out.println("Hello, Java!");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🎯 What Does String[] args Mean?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;String&lt;/strong&gt; → It means text-based data (just like words or sentences).&lt;br&gt;
&lt;strong&gt;[]&lt;/strong&gt; → It represents an array (a collection of values).&lt;br&gt;
&lt;strong&gt;args&lt;/strong&gt; → It is the name of the array that holds command-line arguments.&lt;/p&gt;
&lt;h2&gt;
  
  
  💡 Analogy: A List of Instructions 📜
&lt;/h2&gt;

&lt;p&gt;Imagine you are ordering pizza online:&lt;/p&gt;

&lt;p&gt;You might specify size, crust type, and toppings.&lt;br&gt;
These options are like command-line arguments in Java.&lt;/p&gt;

&lt;p&gt;✅ Example 1: Printing Numbers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println(23 + 34);  

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

&lt;/div&gt;



&lt;p&gt;💡 Output: 57 &lt;br&gt;
(because Java calculates 23 + 34).&lt;/p&gt;
&lt;h2&gt;
  
  
  ✅ Example 2: Printing Text
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("23 + 34");  

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

&lt;/div&gt;


&lt;p&gt;💡 Output: 23 + 34 &lt;br&gt;
(because text inside double quotes is treated as a string, for now string is something like a word or a sentence).&lt;/p&gt;
&lt;h2&gt;
  
  
  📌 What happens when we mix numbers and strings?
&lt;/h2&gt;

&lt;p&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;System.out.println("23" + 34);

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

&lt;/div&gt;



&lt;p&gt;💡 Output: "2334"&lt;/p&gt;

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

&lt;p&gt;"23" is a string, and 34 is a number.&lt;br&gt;
Since one of them is a string, Java treats 34 as text and joins (concatenates) them instead of adding.&lt;br&gt;
This is like writing "Hello" + "World", which results in "HelloWorld".&lt;/p&gt;

&lt;p&gt;🚨 Error Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("23" - 34);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gives an ERROR&lt;/p&gt;

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

&lt;p&gt;The + operator works for both addition and string concatenation.&lt;br&gt;
But the - operator only works with numbers, so "23" - 34 is invalid.&lt;/p&gt;

&lt;p&gt;✅ Key Takeaways&lt;br&gt;
1️⃣ public is like a public park—accessible to all.&lt;br&gt;
2️⃣ class is like a school class, and objects are its students.&lt;br&gt;
3️⃣ main method is like a house entry door—Java always starts here.&lt;br&gt;
4️⃣ System.out.println() is like speaking out loud.&lt;br&gt;
5️⃣ "23" + 34 results in "2334" (string concatenation), but "23" - 34 gives an error.&lt;/p&gt;

&lt;p&gt;🚀 What's Next?&lt;br&gt;
Now that you've understood the Java basics, try writing your own Java program and experiment with different print statements!&lt;/p&gt;

&lt;p&gt;💬 What part of Java confuses you the most? Drop a comment below, and let’s learn together! 🚀&lt;/p&gt;

&lt;p&gt;Happy Coding! 🎉&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
    <item>
      <title>🚀 Understanding Variables in Python</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Wed, 26 Feb 2025 17:19:16 +0000</pubDate>
      <link>https://dev.to/div1904/understanding-variables-in-python-d5a</link>
      <guid>https://dev.to/div1904/understanding-variables-in-python-d5a</guid>
      <description>&lt;p&gt;So, in the last post, we added two numbers, 23 and 34. We gave these numbers to the computer &lt;strong&gt;as input&lt;/strong&gt;, and then it processed them for calculation and gave us the output.&lt;br&gt;
But what if we want to** store numbers** in the computer's memory for later use? This is where variables come into play!&lt;/p&gt;

&lt;p&gt;However, we don’t always have to provide numbers or information directly for processing. Computers can also store data or information in their memory at a specific location with a*&lt;em&gt;n address.&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;Just like you live in a house that has an address, variables in a computer's memory also have a location and an address.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is a Variable?
&lt;/h2&gt;

&lt;p&gt;A variable is a name given to a value stored in the computer's memory. Think of it as a container that holds data, just like a box where you store things.&lt;/p&gt;

&lt;p&gt;For example, if we want to store the numbers 23 and 34 in the computer’s memory as num1 and num2, the computer will store them at memory locations let them loc1 and loc2.&lt;/p&gt;

&lt;p&gt;Now, instead of directly using 23 + 34, we can access these stored numbers anytime using their variable names:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
num1 = 23  &lt;br&gt;
num2 = 34  &lt;br&gt;
print(num1 + num2) &lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will fetch the values stored in num1 and num2, perform the addition, and give us the result as output.&lt;/p&gt;

&lt;p&gt;Similarly, we can store information about ourselves, such as name, age, class, and city, in Python variables and retrieve them using the print() function.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Brian"  
age = 23  
city = "Delhi"  

print(name, age, city)  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Brian 23 Delhi  &lt;/p&gt;

&lt;p&gt;Here, we have stored values in variables and then displayed them using print().&lt;/p&gt;

&lt;p&gt;That's how variables operate and we can use them in our programming to store some kind of data. &lt;/p&gt;

&lt;h2&gt;
  
  
  But while naming variables, we have to follow some rules, which are as follows:
&lt;/h2&gt;

&lt;p&gt;✔ Only letters, digits, and underscores (&lt;em&gt;) are allowed.&lt;br&gt;
✔ No spaces are allowed in variable names.&lt;br&gt;
✔ Cannot use Python keywords like print (we will discuss others later).&lt;br&gt;
✔ A variable must start with a letter or an underscore (&lt;/em&gt;).&lt;br&gt;
✔ Special symbols like @, $, #, &amp;amp; are not allowed.&lt;/p&gt;

&lt;p&gt;for example, 1num or num 1 are invalid but _num1 or num_1 are valid. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>🚀 Understanding Output in Python</title>
      <dc:creator>Divya Dixit</dc:creator>
      <pubDate>Wed, 26 Feb 2025 16:57:43 +0000</pubDate>
      <link>https://dev.to/div1904/understanding-output-in-python-5chk</link>
      <guid>https://dev.to/div1904/understanding-output-in-python-5chk</guid>
      <description>&lt;h2&gt;
  
  
  1. What is Output?
&lt;/h2&gt;

&lt;p&gt;Output refers to anything that appears on the screen or is provided by the computer after performing a task or operation.&lt;/p&gt;

&lt;p&gt;For example, if you tell a computer to add two numbers (23 and 24), it will process the operation and return a result:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This result (47) is called output.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Input?
&lt;/h2&gt;

&lt;p&gt;Whatever data we provide to the computer is called an input. In the above example, we provided 23 and 24 so they are inputs, and 47 is the output.&lt;/p&gt;

&lt;p&gt;🔹 Printing Output in Python&lt;/p&gt;

&lt;p&gt;Python makes printing output super simple! Unlike other programming languages, Python does not require extra formalities or lengthy syntax.&lt;/p&gt;

&lt;p&gt;Python provides the print() function, which is used to display output on the screen.&lt;/p&gt;

&lt;p&gt;📌 Syntax of print() Function:&lt;br&gt;
&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Here, arguments refer to the values or text or anything you want to print.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔹 Example 1: Printing a Word or Sentence
&lt;/h2&gt;

&lt;p&gt;To print a word or sentence, we write it inside double quotes ("") 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;print("Hello, World!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Output:&lt;br&gt;
Hello, World!&lt;/p&gt;

&lt;p&gt;✅ Whatever is written inside quotes is printed exactly as it is.&lt;/p&gt;
&lt;h2&gt;
  
  
  🔹 Example 2: Printing a Mathematical Calculation
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(23 + 34)

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

&lt;/div&gt;


&lt;p&gt;💡 Output:&lt;br&gt;
57&lt;/p&gt;

&lt;p&gt;Here, Python calculates the sum and prints the result.&lt;/p&gt;
&lt;h2&gt;
  
  
  🔹 Example 3: Printing a Number as Text
&lt;/h2&gt;

&lt;p&gt;But if we write numbers inside double quotes, Python will treat them as text (string), not numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("23 + 34")

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

&lt;/div&gt;



&lt;p&gt;💡 Output:&lt;br&gt;
23 + 34&lt;/p&gt;

&lt;p&gt;🔹 Why? Because "23 + 34" is inside double quotes, so Python prints it as it is, without calculating.&lt;/p&gt;
&lt;h2&gt;
  
  
  🔹 Example 4: Printing Multiple Values
&lt;/h2&gt;

&lt;p&gt;You can print multiple values in a single print() statement using commas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("The sum of 23 and 34 is:", 23 + 34)

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

&lt;/div&gt;



&lt;p&gt;💡 Output:&lt;br&gt;
The sum of 23 and 34 is: 57&lt;/p&gt;

&lt;p&gt;Python automatically adds a space between values when separated by commas.&lt;/p&gt;

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

&lt;p&gt;✔ Output is what the computer returns after performing an operation.&lt;br&gt;
✔ Input is the data given to the computer.&lt;br&gt;
✔ Python uses the print() function to display output in a simple way.&lt;br&gt;
✔ Text must be written inside double or single quotes ("text" or 'text').&lt;br&gt;
✔ If a number is written inside quotes, it is treated as text (not calculated).&lt;/p&gt;

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