<?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"><channel><title><![CDATA[Code with Shraddha]]></title><description><![CDATA[Welcome to Code with Shraddha! I'm a Diploma IT student sharing beginner-friendly programming tutorials, software development tips, Python projects, and my jour]]></description><link>https://codewithshraddha.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Code with Shraddha</title><link>https://codewithshraddha.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 16:45:49 GMT</lastBuildDate><atom:link href="https://codewithshraddha.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Python Variables Explained: A Beginner's Guide with Examples]]></title><description><![CDATA[Introduction
Imagine you want your Python program to remember someone's name, age, marks, or even the price of a product.
How can a program store this information?
That's where variables come in.
Vari]]></description><link>https://codewithshraddha.hashnode.dev/python-variables-explained-a-beginner-s-guide-with-examples</link><guid isPermaLink="true">https://codewithshraddha.hashnode.dev/python-variables-explained-a-beginner-s-guide-with-examples</guid><category><![CDATA[python beginner]]></category><category><![CDATA[Basics of Python]]></category><dc:creator><![CDATA[Shraddha Pardeshi]]></dc:creator><pubDate>Sun, 30 Aug 2026 18:20:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a744fee8d848ac2315af393/838e027f-b315-4b89-9667-20ccbf4d3519.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><strong>Introduction</strong></h3>
<p>Imagine you want your Python program to remember someone's <strong>name, age, marks</strong>, or even the <strong>price of a product</strong>.</p>
<p>How can a program store this information?</p>
<p>That's where <strong>variables</strong> come in.</p>
<p>Variables are one of the first concepts you'll learn when starting Python. They allow you to store information and use that information later in your program.</p>
<p><em><strong>For example:</strong></em></p>
<p><strong>name</strong> = "<em>Shraddha</em>"<br /><strong>age</strong> = <em>18</em></p>
<p>Here, <strong>Python</strong> stores "<em>Shraddha</em>" in the variable name and <em>18</em> in the variable age.</p>
<p>In this article, <mark class="bg-yellow-200 dark:bg-yellow-500/30">you'll learn</mark>:</p>
<p><em>•</em> What a variable is<br /><em>•</em> How to create a variable in Python<br /><em>•</em> How Python stores values<br /><em>•</em> Different types of values variables can hold<br /><em>•</em> Rules for naming variables<br /><em>•</em> Multiple variable assignment<br /><em>•</em> How to change a variable's value Common mistakes beginners make<br /><em>•</em> Practical examples</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">Let's get started! 🚀</mark></p>
<p><strong>What Is a Variable in Python?</strong></p>
<p>A <strong>variable is a name used to refer to a value stored by a program.</strong></p>
<p>You can think of a variable as a labeled box.</p>
<p><em><strong>For example:</strong></em></p>
<p>name → │ Shraddha │</p>
<p>The label is <strong>name</strong>, and the value stored inside it is "<em>Shraddha</em>".</p>
<p>In <mark class="bg-yellow-200 dark:bg-yellow-500/30">Python</mark>, you create a variable by assigning a value to a name:</p>
<p><strong>name</strong> = "<em>Shraddha</em>"</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">Here:</mark></p>
<p><strong>name</strong> → variable<br /><strong>=</strong> → assignment operator<br />"<strong>Shraddha</strong>" → value</p>
<p>You can then use the variable:</p>
<p>print(name)</p>
<p>Output :<br /><em>Shraddha</em></p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">💡 Think of it this way:</mark><br />A variable gives your program a name for a piece of information.  </p>
<img src="https://cdn.hashnode.com/uploads/covers/6a744fee8d848ac2315af393/9fd0f364-87d3-4dd7-909f-5da6561ab131.png" alt="" style="display:block;margin:0 auto" />

<h3>How to Create a Variable in Python</h3>
<p>Python doesn't require you to declare the data type of a variable before using it.</p>
<p><em><strong>For example:</strong></em></p>
<p><strong>name</strong> = "Shraddha"<br /><strong>age</strong> = 18<br /><strong>marks</strong> = 85.5</p>
<p>Python automatically determines the type of value being assigned.</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">Let's check them:</mark></p>
<p>print(name)<br />print(age)<br />print(marks)</p>
<p><strong>Output :</strong><br />Shraddha<br />18<br />85.5</p>
<p><em>This makes Python's syntax simple for beginners.</em></p>
<img src="https://cdn.hashnode.com/uploads/covers/6a744fee8d848ac2315af393/edfe6ddc-8693-4a17-b6ca-e3eefa04c999.png" alt="" style="display:block;margin:0 auto" />

<h3>Understanding the Assignment Operator =</h3>
<p>One common mistake beginners make is thinking that = means "equal to" in the mathematical sense.</p>
<p>In Python, <strong>=</strong> is primarily used for assignment.</p>
<p><strong>For example:</strong></p>
<p><em>age</em> = 18</p>
<p><strong>This means:</strong></p>
<p><em>Store the value 18 in the variable age.</em></p>
<p>You can later change the value:</p>
<p><em>age</em> = 19</p>
<p>Now age contains 19.</p>
<p>print(age)</p>
<p>Output<br />19</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">The variable has been updated</mark>.</p>
<h3>Variables Can Store Different Types of Values</h3>
<p>Python variables can refer to different types of data.</p>
<ol>
<li><strong>String</strong></li>
</ol>
<p>A string stores text.<br />name = "Shraddha"</p>
<p>2**. Integer**</p>
<p>An integer stores a whole number.<br />age = 18</p>
<p>3. <strong>Float</strong></p>
<p>A float stores a decimal number.<br />percentage = 86.59</p>
<p>4. <strong>Boolean</strong></p>
<p>A Boolean represents either True or False.<br />is_student = True</p>
<p>These are some of the basic data types you'll frequently use in Python.</p>
<h3>How to Check the Type of a Variable</h3>
<p>Python provides a built-in function called <strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">type()</mark></strong>.</p>
<p><em><strong>For example:</strong></em></p>
<p><strong>name</strong> = "Shraddha"<br /><strong>age</strong> = 18<br /><strong>percentage</strong> = 86.59</p>
<p>print(type(name))<br />print(type(age))<br />print(type(percentage))</p>
<p><strong>Output</strong></p>
<p>&lt;class 'str'&gt;<br />&lt;class 'int'&gt;<br />&lt;class 'float'&gt;</p>
<p><em>This tells us:</em></p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">name is a string age is an integer percentage is a float Changing the Value of a Variable</mark></p>
<p>Variables don't have to keep the same value.</p>
<p><em><strong>For example:</strong></em></p>
<p>city = "Aagra"</p>
<p>print(city)</p>
<p>city = "Mumbai"</p>
<p>print(city)</p>
<p>Output<br />Aagra<br />Mumbai</p>
<p>The value stored in city changed from "Aagra" to "Mumbai".</p>
<p>This is useful when your program needs to work with information that changes.</p>
<h3>Can a Variable Change Its Data Type?</h3>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Yes.</mark></strong></p>
<p>Python is dynamically typed, so a variable can refer to a value of a different type later.</p>
<p><em><strong>For example:</strong></em></p>
<p>value = 10</p>
<p>print(value)</p>
<p>value = "Python"</p>
<p>print(value)</p>
<p><em><strong>Output</strong></em><br />10<br />Python</p>
<p>Initially, value refers to an integer.</p>
<p>Later, it refers to a string.</p>
<p><em>Although Python allows this, beginners should still choose meaningful variable usage to keep their programs easy to understand.</em></p>
<h3>Rules for Naming Variables in Python</h3>
<p>Python has some rules you need to follow when naming variables.</p>
<p><strong>Rule 1:</strong></p>
<p>A variable name can contain letters, numbers, and underscores. student_name = "Shraddha"<br />student_age = 18</p>
<p><strong>Rule 2:</strong></p>
<p>A variable name cannot start with a number.</p>
<p>❌ Incorrect:</p>
<p>1name = "Shraddha"</p>
<p>✅ Correct:</p>
<p>name1 = "Shraddha"</p>
<p><strong>Rule 3:</strong></p>
<p>Don't use spaces.</p>
<p>❌ Incorrect:</p>
<p>student name = "Shraddha"</p>
<p>✅ Correct:</p>
<p>student_name = "Shraddha"</p>
<p><strong>Rule 4:</strong></p>
<p>Python is case-sensitive.</p>
<p>These are different variables:</p>
<p>name = "Shraddha"<br />Name = "Rahul"</p>
<p>name and Name are not the same.</p>
<p><strong>Rule 5:</strong></p>
<p>Don't use Python keywords as variable names.</p>
<p><em>For example</em>, don't use names such as:</p>
<p>if for class while def</p>
<p>These words already have special meanings in Python.</p>
<h3><strong>Good Variable Names vs Bad Variable Names</strong></h3>
<p>Compare these:</p>
<p>❌ Not very descriptive<br />x = 18<br />y = 86.5<br />z = "Shraddha"<br />✅ More descriptive<br />age = 18<br />percentage = 86.5<br />student_name = "Shraddha"</p>
<p>Both may work, but descriptive names make your code much easier to understand.</p>
<p><strong>A useful rule:</strong></p>
<p>Your variable name should tell the reader what the value represents.</p>
<h3>Assigning Multiple Variables</h3>
<p>Python allows you to assign values to multiple variables in one line.</p>
<p><strong>For example:</strong></p>
<p>name, age, city = "Shraddha", 18, "Pune"</p>
<p><strong>Now:</strong></p>
<p>print(name)<br />print(age)<br />print(city)</p>
<p><em><strong>Output</strong></em></p>
<p>Shraddha<br />18<br />Pune</p>
<p>You can also assign the same value to multiple variables:</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">x = y = z = 0</mark></p>
<p>Now all three variables contain 0.</p>
<h3><strong>A Practical Example: Student Information</strong></h3>
<p>Let's combine what we've learned.</p>
<p>student_name = "Shraddha"<br />age = 18<br />percentage = 86.59<br />is_student = True</p>
<p>print("Name:", student_name)<br />print("Age:", age)<br />print("Percentage:", percentage)<br />print("Student:", is_student)</p>
<p><strong>Output</strong><br />Name: Shraddha<br />Age: 18<br />Percentage: 86.59<br />Student: True</p>
<p>This is a simple example of how variables can represent information about a student.</p>
<h3>A Real-World Example: Shopping Cart</h3>
<p>Variables aren't only useful for student programs.</p>
<p>Imagine an online shopping application.</p>
<p>You might have:</p>
<p>product = "Laptop"<br />price = 55000<br />quantity = 2</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">total = price * quantity</mark></p>
<p>print("Product:", product)<br />print("Total:", total)</p>
<p><strong>Output</strong><br />Product: Laptop<br />Total: 110000</p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">Here, variables help the program remember the product, price, quantity, and total amount.</mark></p>
<p>This is how simple programming concepts eventually become part of larger real-world applications.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a744fee8d848ac2315af393/7b474452-6828-4191-a26f-a6b42b81c588.png" alt="" style="display:block;margin:0 auto" />

<h3>Common Mistakes Beginners Make</h3>
<p><strong>1.Using spaces in variable names</strong></p>
<p>❌</p>
<p>student name = "Shraddha"</p>
<p>✅</p>
<p>student_name = "Shraddha"</p>
<p><strong>2. Starting with a number</strong></p>
<p>❌</p>
<p>2name = "Python"</p>
<p>✅</p>
<p>name2 = "Python"</p>
<p><strong>3. Forgetting quotation marks for strings</strong></p>
<p>❌</p>
<p>name = Shraddha</p>
<p>Python will interpret Shraddha as a variable name.</p>
<p>✅</p>
<p>name = "Shraddha"</p>
<p><strong>4. Confusing uppercase and lowercase</strong></p>
<p>name = "Shraddha"</p>
<p>print(Name)</p>
<p>This can produce an error because name and Name are different.</p>
<h3>Best Practices for Naming Variables</h3>
<p>Following a few simple habits can make your code much cleaner.</p>
<p><strong>Use descriptive names</strong></p>
<p><em>student_name = "Shraddha"</em><br />instead of:</p>
<p>x = "Shraddha"</p>
<p><strong>Use snake_case</strong></p>
<p>Python programmers commonly use lowercase words separated by underscores:</p>
<p>student_name<br />total_price<br />phone_number<br />Keep names readable</p>
<p>Avoid unnecessarily complicated names such as:</p>
<blockquote>
<p>the_name_of_the_student_who_is_registered = "Shraddha"</p>
</blockquote>
<p>Prefer:</p>
<blockquote>
<p>student_name = "Shraddha"</p>
</blockquote>
<p>Simple is better.</p>
<h3>Frequently Asked Questions What is a variable in Python?</h3>
<p>A variable is a name that refers to a value used by a program.</p>
<p><strong>Do I need to declare a variable type in Python?</strong></p>
<p>No. Python determines the type of value when you assign it.</p>
<p>For example:</p>
<blockquote>
<p>age = 18</p>
</blockquote>
<p>Python recognizes age as referring to an integer value.</p>
<p><strong>Can I change a variable's value?</strong></p>
<p>Yes.</p>
<blockquote>
<p>age = 18<br />age = 19</p>
</blockquote>
<p>The variable now refers to 19.</p>
<p><strong>Are Python variable names case-sensitive?</strong></p>
<p>Yes.</p>
<blockquote>
<p>name<br />Name</p>
</blockquote>
<p>are treated as different names.</p>
<p><strong>Can a variable name contain numbers?</strong></p>
<p>Yes, but it cannot begin with a number.</p>
<p>✅</p>
<p>student1</p>
<p>❌</p>
<p>1student</p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Practice Challenge 🧩</mark></strong></p>
<p><em><strong>Now it's your turn !</strong></em></p>
<p><strong>Create a Python program that stores the following information:</strong></p>
<p>Your name<br />Your age<br />Your city<br />Your favorite programming language</p>
<p>Then print everything.</p>
<p>Example<br />name = "Your Name"<br />age = 18<br />city = "Your City"<br />favorite_language = "Python"</p>
<p>print("Name:", name)<br />print("Age:", age)<br />print("City:", city)<br />print("Favorite Language:", favorite_language)</p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Challenge</mark></strong></p>
<p><strong>Try modifying the program to also store:</strong></p>
<p>Your college<br />Your course<br />Your percentage</p>
<p><em>Don't just copy the code—type it yourself and experiment with it.</em></p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">What's Next?</mark></p>
<p>Now that you understand variables, the next important topic is <strong>Python Data Types.</strong></p>
<p><em>You'll learn how Python works with:</em></p>
<p><em>•</em> Strings<br /><em>•</em> Integers<br /><em>•</em> Floats<br /><em>•</em> Booleans<br /><em>•</em> Lists<br /><em>•</em> Tuples<br /><em>•</em> Dictionaries<br /><em>•</em> Sets</p>
<p><strong>Understanding data types will make it much easier to work with real programs.</strong></p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Conclusion</mark></strong></p>
<p>Variables are one of the fundamental building blocks of Python programming.</p>
<p>They allow programs to store and work with information such as names, numbers, prices, and user input.</p>
<p>You've now learned how to:</p>
<p><em>•</em> Create variables<br /><em>•</em> Assign values<br /><em>•</em> Check data types<br /><em>•</em> Change values<br /><em>•</em> Assign multiple variables<br /><em>•</em> Follow Python naming rules<br /><em>•</em> Use variables in practical programs</p>
<p>Don't stop at reading. Open your Python editor and experiment with different values.</p>
<p><strong>The more you practice, the more naturally programming concepts will start to make sense.</strong></p>
<p>Happy Coding! 🐍💻</p>
<p>📚 <strong><mark class="bg-yellow-200 dark:bg-yellow-500/30"> Continue the Series</mark></strong></p>
<p><strong>Previous: [Python for Beginners: A Complete Guide with Examples]</strong></p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Next: Python Data Types Explained with Examples (Coming Soon)</mark></strong></p>
<p>💡 <em>If this article helped you, follow Code with Shraddha for more beginner-friendly Python tutorials, practical programming examples, and IT-student-focused content.</em></p>
<p><em>References</em></p>
<p><em>Python Documentation — Variables and Naming</em><br /><em>Python Documentation — Built-in Functions</em><br /><em>Python Documentation — Data Types</em></p>
]]></content:encoded></item></channel></rss>