<?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 Shravgorde on Medium]]></title>
        <description><![CDATA[Stories by Shravgorde on Medium]]></description>
        <link>https://medium.com/@shravgorde?source=rss-74673e28845a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LdNH05UGQRmg4jWW</url>
            <title>Stories by Shravgorde on Medium</title>
            <link>https://medium.com/@shravgorde?source=rss-74673e28845a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:36:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shravgorde/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[Python Data Types Explained: A Beginner’s Guide with Examples]]></title>
            <link>https://medium.com/@shravgorde/python-data-types-explained-a-beginners-guide-with-examples-a7e18ffcf3e0?source=rss-74673e28845a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7e18ffcf3e0</guid>
            <dc:creator><![CDATA[Shravgorde]]></dc:creator>
            <pubDate>Tue, 25 Aug 2026 05:44:04 GMT</pubDate>
            <atom:updated>2026-08-25T05:44:04.935Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is one of the most popular programming languages in the world because of its simple syntax and powerful features.</p><p>If you are starting your Python journey, one of the first concepts you need to understand is <strong>data types</strong>.</p><p>Data types tell Python what kind of value a variable contains. For example, a person’s age is a number, their name is text, and whether they are logged in can be represented as either True or False.</p><p>In this article, we’ll learn about the most important <strong>data types in Python</strong>, with simple examples that beginners can easily understand.</p><h3>What Are Data Types in Python?</h3><p>A data type defines the type of data that a variable can store.</p><p>For example:</p><pre>name = &quot;Rahul&quot;<br>age = 25<br>height = 5.8<br>is_student = True</pre><p>Here:</p><ul><li>name contains text, so it is a <strong>string</strong></li><li>age contains a whole number, so it is an <strong>integer</strong></li><li>height contains a decimal number, so it is a <strong>float</strong></li><li>is_student contains True, so it is a <strong>boolean</strong></li></ul><p>Python automatically determines the data type when you assign a value to a variable.</p><p>You don’t need to explicitly declare the type.</p><h3>Main Data Types in Python</h3><p>Python has several built-in data types. The most commonly used ones are:</p><ol><li>Numbers</li><li>Strings</li><li>Lists</li><li>Tuples</li><li>Sets</li><li>Dictionaries</li><li>Booleans</li><li>None</li></ol><p>Let’s understand each one.</p><h3>1. Integer (int)</h3><p>An integer is a whole number without a decimal point.</p><p>Examples:</p><pre>age = 25<br>year = 2026<br>temperature = -5</pre><p>You can check the type using the type() function:</p><pre>age = 25</pre><pre>print(type(age))</pre><p>Output:</p><pre>&lt;class &#39;int&#39;&gt;</pre><p>Integers can be positive, negative, or zero.</p><pre>x = 100<br>y = -20<br>z = 0</pre><p>All three variables are integers.</p><h3>Integer Operations</h3><p>Python allows you to perform mathematical operations on integers.</p><pre>a = 10<br>b = 3</pre><pre>print(a + b)<br>print(a - b)<br>print(a * b)<br>print(a / b)</pre><p>Output:</p><pre>13<br>7<br>30<br>3.3333333333333335</pre><h3>2. Float (float)</h3><p>A float represents a number containing a decimal point.</p><p>Examples:</p><pre>price = 99.99<br>height = 5.8<br>pi = 3.14159</pre><p>Check its type:</p><pre>price = 99.99</pre><pre>print(type(price))</pre><p>Output:</p><pre>&lt;class &#39;float&#39;&gt;</pre><p>Floats are commonly used for measurements, prices, percentages, scientific calculations, and other values that require decimals.</p><p>For example:</p><pre>product_price = 499.50<br>discount = 10.5</pre><h3>3. String (str)</h3><p>A string is a sequence of characters.</p><p>Strings are written inside quotes.</p><pre>name = &quot;Shrav&quot;<br>city = &quot;Mumbai&quot;<br>message = &quot;Welcome to Python!&quot;</pre><p>You can use either single quotes or double quotes:</p><pre>name = &#39;Shrav&#39;<br>name = &quot;Shrav&quot;</pre><p>Both are valid.</p><p>Check the type:</p><pre>name = &quot;Shrav&quot;</pre><pre>print(type(name))</pre><p>Output:</p><pre>&lt;class &#39;str&#39;&gt;</pre><h3>String Operations</h3><p>You can combine strings using the + operator.</p><pre>first_name = &quot;Shrav&quot;<br>last_name = &quot;Gorde&quot;</pre><pre>full_name = first_name + &quot; &quot; + last_name</pre><pre>print(full_name)</pre><p>Output:</p><pre>Shrav Gorde</pre><p>You can also access individual characters using indexing.</p><pre>language = &quot;Python&quot;</pre><pre>print(language[0])<br>print(language[1])</pre><p>Output:</p><pre>P<br>y</pre><p>Python indexing starts from <strong>0</strong>, not 1.</p><h3>4. List (list)</h3><p>A list is a collection of items.</p><p>Lists are:</p><ul><li>Ordered</li><li>Changeable (mutable)</li><li>Able to contain duplicate values</li></ul><p>Example:</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;]</pre><p>You can access elements using their index:</p><pre>print(fruits[0])</pre><p>Output:</p><pre>apple</pre><h3>Lists Can Contain Different Data Types</h3><p>Python lists can contain different types of values.</p><pre>student = [&quot;Shrav&quot;, 25, 5.8, True]</pre><p>This list contains:</p><ul><li>String</li><li>Integer</li><li>Float</li><li>Boolean</li></ul><h3>Modifying a List</h3><p>Because lists are mutable, you can change their values.</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;]</pre><pre>fruits[1] = &quot;orange&quot;</pre><pre>print(fruits)</pre><p>Output:</p><pre>[&#39;apple&#39;, &#39;orange&#39;, &#39;mango&#39;]</pre><p>You can also add items:</p><pre>fruits.append(&quot;grapes&quot;)</pre><p>Lists are extremely useful when you need to store a collection of items that may change during program execution.</p><h3>5. Tuple (tuple)</h3><p>A tuple is similar to a list, but it is <strong>immutable</strong>.</p><p>That means once a tuple is created, its elements cannot be changed.</p><p>Example:</p><pre>coordinates = (10, 20)</pre><p>Check its type:</p><pre>print(type(coordinates))</pre><p>Output:</p><pre>&lt;class &#39;tuple&#39;&gt;</pre><p>You can access tuple elements just like lists:</p><pre>print(coordinates[0])</pre><p>Output:</p><pre>10</pre><p>But this will cause an error:</p><pre>coordinates[0] = 50</pre><p>Why?</p><p>Because tuples cannot be modified after they are created.</p><h3>When Should You Use a Tuple?</h3><p>Tuples are useful when you have a collection of values that should remain unchanged.</p><p>For example:</p><pre>rgb = (255, 255, 255)</pre><h3>6. Set (set)</h3><p>A set is an unordered collection of unique values.</p><p>The most important feature of a set is that it <strong>does not allow duplicate elements</strong>.</p><p>Example:</p><pre>numbers = {1, 2, 3, 4, 5}</pre><p>If you add duplicate values:</p><pre>numbers = {1, 2, 2, 3, 3, 4}</pre><pre>print(numbers)</pre><p>You will get something similar to:</p><pre>{1, 2, 3, 4}</pre><p>The duplicate values are removed.</p><h3>Adding Elements to a Set</h3><pre>numbers = {1, 2, 3}</pre><pre>numbers.add(4)</pre><pre>print(numbers)</pre><p>Output:</p><pre>{1, 2, 3, 4}</pre><p>Sets are especially useful when you need to remove duplicates or perform mathematical set operations such as union and intersection.</p><h3>7. Dictionary (dict)</h3><p>A dictionary stores data in <strong>key-value pairs</strong>.</p><p>It is one of the most useful data types in Python.</p><p>Example:</p><pre>student = {<br>    &quot;name&quot;: &quot;Shrav&quot;,<br>    &quot;age&quot;: 25,<br>    &quot;city&quot;: &quot;Mumbai&quot;<br>}</pre><p>Here:</p><ul><li>&quot;name&quot; is a key</li><li>&quot;Shrav&quot; is its value</li><li>&quot;age&quot; is a key</li><li>25 is its value</li></ul><p>You can access values using their keys:</p><pre>print(student[&quot;name&quot;])</pre><p>Output:</p><pre>Shrav</pre><p>You can also add new key-value pairs:</p><pre>student[&quot;course&quot;] = &quot;Python&quot;</pre><p>Now the dictionary contains:</p><pre>{<br>    &quot;name&quot;: &quot;Shrav&quot;,<br>    &quot;age&quot;: 25,<br>    &quot;city&quot;: &quot;Mumbai&quot;,<br>    &quot;course&quot;: &quot;Python&quot;<br>}</pre><p>Dictionaries are commonly used when working with structured data, APIs, JSON, databases, and real-world application data.</p><h3>8. Boolean (bool)</h3><p>A Boolean represents one of two values:</p><pre>True<br>False</pre><p>Example:</p><pre>is_logged_in = True<br>is_admin = False</pre><p>Check the type:</p><pre>print(type(is_logged_in))</pre><p>Output:</p><pre>&lt;class &#39;bool&#39;&gt;</pre><p>Boolean are commonly used in conditions.</p><pre>age = 20</pre><pre>if age &gt;= 18:<br>    print(&quot;You are an adult.&quot;)</pre><p>Output:</p><pre>You are an adult.</pre><p>The expression:</p><pre>age &gt;= 18</pre><p>returns a Boolean value.</p><h3>9. None (NoneType)</h3><p>Python also has a special value called None.</p><p>None represents the absence of a value.</p><p>Example:</p><pre>result = None</pre><p>Check its type:</p><pre>print(type(result))</pre><p>Output:</p><pre>&lt;class &#39;NoneType&#39;&gt;</pre><p>None is commonly used when a variable currently has no value.</p><p>For example:</p><pre>user_data = None</pre><p>Later, the variable might contain actual data:</p><pre>user_data = {<br>    &quot;name&quot;: &quot;Shrav&quot;,<br>    &quot;age&quot;: 25<br>}</pre><h3>Mutable vs Immutable Data Types</h3><p>One important concept in Python is the difference between <strong>mutable</strong> and <strong>immutable</strong> objects.</p><h3>Mutable</h3><p>Mutable objects can be changed after they are created.</p><p>Examples include:</p><pre>list<br>set<br>dictionary</pre><p>For example:</p><pre>numbers = [1, 2, 3]</pre><pre>numbers.append(4)</pre><pre>print(numbers)</pre><p>The original list has been modified.</p><h3>Immutable</h3><p>Immutable objects cannot be changed after they are created.</p><p>Examples include:</p><pre>int<br>float<br>string<br>tuple<br>bool</pre><p>For example:</p><pre>name = &quot;Python&quot;</pre><p>You cannot directly modify an individual character of the string.</p><pre>name[0] = &quot;J&quot;</pre><p>This produces an error because strings are immutable.</p><h3>How to Check the Data Type</h3><p>Python provides the built-in type() function to check the type of a value.</p><pre>x = 100</pre><pre>print(type(x))</pre><p>Output:</p><pre>&lt;class &#39;int&#39;&gt;</pre><p>More examples:</p><pre>print(type(10))<br>print(type(10.5))<br>print(type(&quot;Hello&quot;))<br>print(type([1, 2, 3]))<br>print(type((1, 2, 3)))<br>print(type({1, 2, 3}))<br>print(type({&quot;name&quot;: &quot;Shrav&quot;}))<br>print(type(True))<br>print(type(None))</pre><h3>Python Data Types at a Glance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*lrMsyqKoLSzQTWOlk4FQQg.png" /></figure><h3>Type Conversion in Python</h3><p>Sometimes you need to convert one data type into another.</p><p>Python provides built-in functions for this.</p><p>For example, converting a string into an integer:</p><pre>age = &quot;25&quot;</pre><pre>age = int(age)</pre><pre>print(type(age))</pre><p>Output:</p><pre>&lt;class &#39;int&#39;&gt;</pre><h3>Common Type Conversion Functions</h3><pre>int()<br>float()<br>str()<br>list()<br>tuple()<br>set()<br>dict()<br>bool()</pre><p>Example:</p><pre>number = 10</pre><pre>print(float(number))<br>print(str(number))</pre><p>Output:</p><pre>10.0<br>&quot;10&quot;</pre><p>Type conversion is very common when working with user input.</p><p>For example:</p><pre>age = input(&quot;Enter your age: &quot;)</pre><pre>age = int(age)</pre><pre>print(age + 1)</pre><p>The input() function returns a string, so we convert it into an integer before performing arithmetic.</p><h3>A Simple Real-World Example</h3><p>Let’s combine multiple Python data types in one example.</p><pre>student = {<br>    &quot;name&quot;: &quot;Shrav&quot;,<br>    &quot;age&quot;: 25,<br>    &quot;marks&quot;: 85.5,<br>    &quot;subjects&quot;: [&quot;Python&quot;, &quot;SQL&quot;, &quot;Data Science&quot;],<br>    &quot;is_passed&quot;: True<br>}</pre><p>This single dictionary contains several data types:</p><pre>name       → string<br>age        → integer<br>marks      → float<br>subjects   → list<br>is_passed  → boolean</pre><p>This is similar to how real applications store information about users, products, students, employees, and other entities.</p><h3>Why Are Data Types Important?</h3><p>Understanding data types is important because different types of data behave differently.</p><p>For example:</p><pre>x = 10<br>y = 20</pre><pre>print(x + y)</pre><p>Output:</p><pre>30</pre><p>But with strings:</p><pre>x = &quot;10&quot;<br>y = &quot;20&quot;</pre><pre>print(x + y)</pre><p>Output:</p><pre>1020</pre><p>Why?</p><p>Because Python treats them as strings and combines them instead of performing numerical addition.</p><p>This is why understanding data types helps you avoid unexpected results and errors in your programs.</p><h3>Final Thoughts</h3><p>Data types are one of the fundamental concepts every Python developer should understand.</p><p>The most commonly used Python data types are:</p><ul><li><strong>Integer (</strong><strong>int)</strong> — whole numbers</li><li><strong>Float (</strong><strong>float)</strong> — decimal numbers</li><li><strong>String (</strong><strong>str)</strong> — text</li><li><strong>List (</strong><strong>list)</strong> — ordered, changeable collection</li><li><strong>Tuple (</strong><strong>tuple)</strong> — ordered, unchangeable collection</li><li><strong>Set (</strong><strong>set)</strong> — collection of unique values</li><li><strong>Dictionary (</strong><strong>dict)</strong> — key-value pairs</li><li><strong>Boolean (</strong><strong>bool)</strong> — True or False</li><li><strong>NoneType</strong> — represents no value</li></ul><p>The best way to learn them is not just to read about them — <strong>write small Python programs and experiment with each type yourself.</strong></p><h3>Conclusion</h3><p>Understanding data types is one of the most important steps when learning Python. Data types determine how Python stores, processes, and works with different kinds of data.</p><p>From simple types like int, float, str, and bool to powerful data structures like list, tuple, set, and dict, each type has its own purpose and use cases.</p><p>Once you have a good understanding of Python data types, you’ll find it much easier to learn concepts such as loops, functions, data structures, APIs, and object-oriented programming.</p><p>The best way to master data types is through practice. Try creating variables, changing their values, checking their types, and experimenting with different operations.</p><p><strong>Learn the basics, practice consistently, and build small projects — that’s how you become confident in Python. 🐍</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7e18ffcf3e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>