<?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 Warkadkrishna on Medium]]></title>
        <description><![CDATA[Stories by Warkadkrishna on Medium]]></description>
        <link>https://medium.com/@warkadkrishna21?source=rss-fcdf1bc7bd85------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eX8MjwX1gjQSU7X8</url>
            <title>Stories by Warkadkrishna on Medium</title>
            <link>https://medium.com/@warkadkrishna21?source=rss-fcdf1bc7bd85------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:06:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@warkadkrishna21/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: A Beginner-Friendly Guide]]></title>
            <link>https://medium.com/@warkadkrishna21/python-data-types-a-beginner-friendly-guide-cd113d90cecf?source=rss-fcdf1bc7bd85------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd113d90cecf</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-types-in-python]]></category>
            <dc:creator><![CDATA[Warkadkrishna]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 05:35:41 GMT</pubDate>
            <atom:updated>2026-10-06T05:35:41.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is one of the most popular programming languages because it is simple to learn, easy to read, and powerful enough for everything from web development to data science and artificial intelligence.</p><p>One of the first concepts every Python beginner should understand is <strong>data types</strong>.</p><p>In this article, we’ll learn what data types are, the most commonly used data types in Python, and how to work with them using simple examples.</p><h3>What Are Data Types in Python?</h3><p>A <strong>data type</strong> tells Python what kind of value a variable contains.</p><p>For example:</p><pre>name = &quot;Rahul&quot;<br>age = 25<br>salary = 45000.50<br>is_employee = True</pre><p>Here:</p><ul><li>name is a <strong>string</strong></li><li>age is an <strong>integer</strong></li><li>salary is a <strong>float</strong></li><li>is_employee 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 can check the type of a value using the type() function.</p><pre>name = &quot;Rahul&quot;<br>print(type(name))</pre><p>Output:</p><pre>&lt;class &#39;str&#39;&gt;</pre><h3>Main Data Types in Python</h3><p>Python has several built-in data types. The most commonly used ones are:</p><ol><li>String (str)</li><li>Integer (int)</li><li>Float (float)</li><li>Complex (complex)</li><li>Boolean (bool)</li><li>List (list)</li><li>Tuple (tuple)</li><li>Set (set)</li><li>Dictionary (dict)</li><li>None (NoneType)</li></ol><p>Let’s understand each one.</p><h3>1. String (str)</h3><p>A string is a sequence of characters.</p><p>Strings are used to store text such as names, addresses, messages, and sentences.</p><pre>name = &quot;Rahul&quot;<br>city = &quot;Pune&quot;<br>message = &quot;Welcome to Python&quot;</pre><p>You can use either single quotes or double quotes.</p><pre>name = &#39;Rahul&#39;<br>city = &quot;Pune&quot;</pre><p>You can also perform operations on strings.</p><pre>first_name = &quot;Rahul&quot;<br>last_name = &quot;Patil&quot;</pre><pre>full_name = first_name + &quot; &quot; + last_name</pre><pre>print(full_name)</pre><p>Output:</p><pre>Rahul Patil</pre><p>You can find the length of a string using len().</p><pre>name = &quot;Python&quot;</pre><pre>print(len(name))</pre><p>Output:</p><pre>6</pre><h3>Useful String Methods</h3><pre>text = &quot;python programming&quot;</pre><pre>print(text.upper())<br>print(text.lower())<br>print(text.capitalize())</pre><p>Output:</p><pre>PYTHON PROGRAMMING<br>python programming<br>Python programming</pre><h3>2. Integer (int)</h3><p>An integer is a whole number without a decimal point.</p><p>Examples:</p><pre>age = 25<br>marks = 90<br>year = 2026<br>temperature = -5</pre><p>You can perform mathematical operations with integers.</p><pre>a = 10<br>b = 5</pre><pre>print(a + b)<br>print(a - b)<br>print(a * b)<br>print(a / b)</pre><p>Output:</p><pre>15<br>5<br>50<br>2.0</pre><p>Note that / produces a float in Python, even when both numbers are integers.</p><p>For example:</p><pre>print(10 / 2)</pre><p>Output:</p><pre>5.0</pre><h3>3. 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>percentage = 87.5</pre><p>You can perform mathematical operations with floats.</p><pre>price = 100.50<br>discount = 10.25</pre><pre>final_price = price - discount</pre><pre>print(final_price)</pre><p>Output:</p><pre>90.25</pre><h3>4. Complex (complex)</h3><p>Python also supports complex numbers.</p><p>A complex number has a real part and an imaginary part.</p><p>Example:</p><pre>number = 3 + 4j</pre><pre>print(number)</pre><p>Output:</p><pre>(3+4j)</pre><p>You can access the real and imaginary parts separately.</p><pre>number = 3 + 4j</pre><pre>print(number.real)<br>print(number.imag)</pre><p>Output:</p><pre>3.0<br>4.0</pre><p>Complex numbers are mainly used in areas such as mathematics, engineering, and scientific computing.</p><h3>5. Boolean (bool)</h3><p>A Boolean data type has only two possible values:</p><ul><li>True</li><li>False</li></ul><p>Booleans are commonly used in conditions and decision-making.</p><pre>is_logged_in = True<br>is_admin = False</pre><pre>print(is_logged_in)<br>print(is_admin)</pre><p>Output:</p><pre>True<br>False</pre><p>For example:</p><pre>age = 20</pre><pre>print(age &gt;= 18)</pre><p>Output:</p><pre>True</pre><p>This is because the condition age &gt;= 18 is true.</p><h3>6. List (list)</h3><p>A list is used to store multiple values in a single variable.</p><p>Lists are:</p><ul><li>Ordered</li><li>Mutable</li><li>Allow duplicate values</li></ul><p>Example:</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;]</pre><pre>print(fruits)</pre><p>Output:</p><pre>[&#39;apple&#39;, &#39;banana&#39;, &#39;orange&#39;]</pre><p>You can access individual elements using their index.</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;]</pre><pre>print(fruits[0])<br>print(fruits[1])</pre><p>Output:</p><pre>apple<br>banana</pre><p>Python uses <strong>zero-based indexing</strong>, which means the first element has index 0.</p><h3>Lists Are Mutable</h3><p>You can change elements in a list.</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;]</pre><pre>fruits[1] = &quot;mango&quot;</pre><pre>print(fruits)</pre><p>Output:</p><pre>[&#39;apple&#39;, &#39;mango&#39;, &#39;orange&#39;]</pre><p>You can also add new elements.</p><pre>fruits.append(&quot;grapes&quot;)</pre><pre>print(fruits)</pre><h3>7. Tuple (tuple)</h3><p>A tuple is similar to a list, but it is <strong>immutable</strong>.</p><p>This means that once a tuple is created, its elements cannot be changed.</p><p>Example:</p><pre>colors = (&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;)</pre><pre>print(colors)</pre><p>You can access tuple elements using indexes.</p><pre>print(colors[0])</pre><p>Output:</p><pre>red</pre><p>But this will cause an error:</p><pre>colors[0] = &quot;yellow&quot;</pre><p>Tuples are useful when you want to store data that should not be modified.</p><h3>8. Set (set)</h3><p>A set is an unordered collection of unique values.</p><p>Sets automatically remove duplicate values.</p><p>Example:</p><pre>numbers = {1, 2, 3, 4, 4, 5}</pre><pre>print(numbers)</pre><p>Output:</p><pre>{1, 2, 3, 4, 5}</pre><p>Notice that the duplicate 4 appears only once.</p><p>You can add values to a set using add().</p><pre>numbers = {1, 2, 3}</pre><pre>numbers.add(4)</pre><pre>print(numbers)</pre><p>Sets are particularly useful when you need to work with unique values or perform mathematical set operations.</p><h3>9. Dictionary (dict)</h3><p>A dictionary stores data in <strong>key-value pairs</strong>.</p><p>Dictionaries are extremely useful in Python and are commonly used when working with structured data.</p><p>Example:</p><pre>student = {<br>    &quot;name&quot;: &quot;Rahul&quot;,<br>    &quot;age&quot;: 21,<br>    &quot;course&quot;: &quot;Python&quot;<br>}</pre><pre>print(student)</pre><p>You can access a value using its key.</p><pre>print(student[&quot;name&quot;])</pre><p>Output:</p><pre>Rahul</pre><p>You can add or update values.</p><pre>student[&quot;age&quot;] = 22<br>student[&quot;city&quot;] = &quot;Pune&quot;</pre><pre>print(student)</pre><p>A dictionary is useful when you want to represent information about an object.</p><p>For example:</p><pre>employee = {<br>    &quot;name&quot;: &quot;Amit&quot;,<br>    &quot;department&quot;: &quot;IT&quot;,<br>    &quot;salary&quot;: 50000<br>}</pre><p>Here, each key describes the corresponding value.</p><h3>10. None (NoneType)</h3><p>None represents the absence of a value.</p><p>Example:</p><pre>result = None</pre><pre>print(result)</pre><p>Output:</p><pre>None</pre><p>You will often see None when a variable does not currently have a value or when a function doesn&#39;t explicitly return a value.</p><p>For example:</p><pre>def hello():<br>    print(&quot;Hello&quot;)</pre><pre>result = hello()</pre><pre>print(result)</pre><p>The function prints Hello, but it doesn&#39;t return anything, so result contains None.</p><h3>Checking the Data Type</h3><p>Python provides the type() function to determine the data type of a value.</p><pre>name = &quot;Rahul&quot;<br>age = 25<br>salary = 50000.50<br>skills = [&quot;Python&quot;, &quot;SQL&quot;]</pre><pre>print(type(name))<br>print(type(age))<br>print(type(salary))<br>print(type(skills))</pre><p>Output:</p><pre>&lt;class &#39;str&#39;&gt;<br>&lt;class &#39;int&#39;&gt;<br>&lt;class &#39;float&#39;&gt;<br>&lt;class &#39;list&#39;&gt;</pre><h3>Type Conversion in Python</h3><p>Sometimes you need to convert one data type into another.</p><p>This is called <strong>type conversion</strong> or <strong>type casting</strong>.</p><p>For example, you can convert a string into an integer using int().</p><pre>age = &quot;25&quot;</pre><pre>age = int(age)</pre><pre>print(age)<br>print(type(age))</pre><p>Output:</p><pre>25<br>&lt;class &#39;int&#39;&gt;</pre><h3>Common Type Conversion Functions</h3><p>FunctionConverts To int()Integer float()Float str()String list()List tuple()Tuple set()Set bool()Boolean</p><p>Example:</p><pre>number = 10</pre><pre>print(float(number))<br>print(str(number))</pre><p>Output:</p><pre>10.0<br>10</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:</p><ul><li>List</li><li>Dictionary</li><li>Set</li></ul><pre>numbers = [1, 2, 3]</pre><pre>numbers.append(4)</pre><pre>print(numbers)</pre><p>The list has been modified.</p><h3>Immutable</h3><p>Immutable objects cannot be changed after they are created.</p><p>Examples:</p><ul><li>Integer</li><li>Float</li><li>String</li><li>Tuple</li><li>Boolean</li></ul><p>For example:</p><pre>name = &quot;Python&quot;</pre><pre>name = name + &quot; Programming&quot;</pre><pre>print(name)</pre><p>Technically, Python creates a new string rather than modifying the original string.</p><h3>Python Data Types Cheat Sheet</h3><p>Here is a quick summary:</p><p>Data TypeExampleMutable? int10No float10.5No complex2 + 3jNo str&quot;Hello&quot;No boolTrueNo list[1, 2, 3]Yes tuple(1, 2, 3)No set{1, 2, 3}Yes dict{&quot;name&quot;: &quot;Rahul&quot;}Yes NoneTypeNoneNo</p><h3>Conclusion</h3><p>Understanding data types is one of the most important steps when learning Python.</p><p>The most commonly used data types are:</p><ul><li><strong>String</strong> for text</li><li><strong>Integer</strong> for whole numbers</li><li><strong>Float</strong> for decimal numbers</li><li><strong>Boolean</strong> for true/false values</li><li><strong>List</strong> for ordered collections</li><li><strong>Tuple</strong> for immutable collections</li><li><strong>Set</strong> for unique values</li><li><strong>Dictionary</strong> for key-value data</li><li><strong>None</strong> for representing the absence of a value</li></ul><p>Once you understand these data types, concepts such as variables, functions, loops, conditions, and data structures become much easier to learn.</p><p>If you’re starting your Python journey, practice creating variables using each data type and experiment with changing, accessing, and converting them.</p><p><strong>Happy Coding! 🐍</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd113d90cecf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>