{"id":10652,"date":"2025-08-25T10:26:01","date_gmt":"2025-08-25T10:26:01","guid":{"rendered":"https:\/\/www.kaashivinfotech.com\/blog\/?p=10652"},"modified":"2025-08-25T10:26:01","modified_gmt":"2025-08-25T10:26:01","slug":"data-types-in-python-complete-guide","status":"publish","type":"post","link":"https:\/\/www.kaashivinfotech.com\/blog\/data-types-in-python-complete-guide\/","title":{"rendered":"Data Types in Python: Complete Guide to Every Type of Data in Python with Examples"},"content":{"rendered":"<h2>Introduction: Why Learn Data Types in Python?<\/h2>\n<p>Back when I was first learning how to code in Python, one of the hardest topics for me to grasp was data types in Python. All programming languages have their own syntax to work with numbers, text, and collections, and Python is no different. Defining which data type a variable is essentially gives you information on how to write your code, and which data types are efficient.<\/p>\n<p>In this article, we will go through all the data types in Python, discuss how they may be used in real life, and provide examples of code that you can use right away. When you finish this article, you will not only understand variables and built-in types in Python, you will also know how to choose the right variable for your next project.<\/p>\n<h2>What Are Data Types in Python?<\/h2>\n<p>A data type will indicate what kind of value a variable can take or what operation can be performed on it. For example:<\/p>\n<p>x = 10\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # this is an integer<\/p>\n<p>y = &#8220;Python&#8221;\u00a0 # this is a string<\/p>\n<p>z = 3.14\u00a0\u00a0\u00a0\u00a0\u00a0 # this is a float<\/p>\n<p>x is an integer; y is a string; z is a float. Each value is a different type of data in Python.<\/p>\n<p>The two main types in Python are:<\/p>\n<ul>\n<li>Primitive Data Types (or any basic built-in type such as int, float, str, bool)<\/li>\n<li>Non-Primitive \/ Collection Data Types (such as list, tuple, set, dictionary)<\/li>\n<\/ul>\n<h2>Types of Data in Python (with Examples)<\/h2>\n<figure id=\"attachment_10662\" aria-describedby=\"caption-attachment-10662\" style=\"width: 731px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-10662 size-full\" src=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Data-Types-in-Python-2.webp\" alt=\"data types in python\" width=\"731\" height=\"269\" srcset=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Data-Types-in-Python-2.webp 731w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Data-Types-in-Python-2-300x110.webp 300w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Data-Types-in-Python-2-380x140.webp 380w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><figcaption id=\"caption-attachment-10662\" class=\"wp-caption-text\">Data Types in Python<\/figcaption><\/figure>\n<p data-start=\"3252\" data-end=\"3326\">Let\u2019s go step by step through the <strong data-start=\"3286\" data-end=\"3323\">different types of data in Python<\/strong>.<\/p>\n<h3 data-start=\"3328\" data-end=\"3352\">1. Integer (int)<\/h3>\n<ul>\n<li data-start=\"3355\" data-end=\"3411\">Whole numbers, positive or negative, without decimals.<\/li>\n<\/ul>\n<p><span data-state=\"closed\">age = <\/span>25print(type(age))\u00a0 # &lt;class &#8216;int&#8217;&gt;<\/p>\n<h3 data-start=\"3470\" data-end=\"3494\">2. Float (float)<\/h3>\n<ul>\n<li data-start=\"3497\" data-end=\"3521\">Numbers with decimals.<\/li>\n<\/ul>\n<p><span data-state=\"closed\">pi = <\/span>3.14159print(type(pi))\u00a0 # &lt;class &#8216;float&#8217;&gt;<\/p>\n<h3 data-start=\"3585\" data-end=\"3613\">3. Complex (complex)<\/h3>\n<ul>\n<li data-start=\"3616\" data-end=\"3656\">Numbers with real and imaginary parts.<\/li>\n<\/ul>\n<p><span data-state=\"closed\">z = <\/span>5 + 3jprint(type(z))\u00a0 # &lt;class &#8216;complex&#8217;&gt;<\/p>\n<h3 data-start=\"3719\" data-end=\"3742\">4. String (str)<\/h3>\n<ul>\n<li data-start=\"3745\" data-end=\"3771\">Text enclosed in quotes.<\/li>\n<\/ul>\n<p><span data-state=\"closed\">name = <\/span>&#8220;Python&#8221;print(type(name))\u00a0 # &lt;class &#8216;str&#8217;&gt;<\/p>\n<h3 data-start=\"3838\" data-end=\"3863\">5. Boolean (bool)<\/h3>\n<ul>\n<li data-start=\"3866\" data-end=\"3902\">Logical values: True or False.<\/li>\n<\/ul>\n<p><span data-state=\"closed\">is_active = <\/span>Trueprint(type(is_active))\u00a0 # &lt;class &#8216;bool&#8217;&gt;<\/p>\n<h2>Collection Data Types in Python<\/h2>\n<p data-start=\"4020\" data-end=\"4098\">Python also provides powerful <strong data-start=\"4050\" data-end=\"4069\">data structures<\/strong> to handle multiple values.<\/p>\n<h3 data-start=\"4100\" data-end=\"4143\">6. List (list) \u2013 Mutable Collection<\/h3>\n<p><span data-state=\"closed\">fruits = [<\/span>&#8220;apple&#8221;, &#8220;banana&#8221;, &#8220;cherry&#8221;]print(type(fruits))\u00a0 # &lt;class &#8216;list&#8217;&gt;<\/p>\n<h3 data-start=\"4236\" data-end=\"4283\">7. Tuple (tuple) \u2013 Immutable Collection<\/h3>\n<p><span data-state=\"closed\">coordinates = (<\/span>10, 20)print(type(coordinates))\u00a0 # &lt;class &#8216;tuple&#8217;&gt;<\/p>\n<h3 data-start=\"4366\" data-end=\"4404\">8. Set (set) \u2013 Unique Elements<\/h3>\n<p><span data-state=\"closed\">unique_nums = {<\/span>1, 2, 3, 3}print(unique_nums)\u00a0 # {1, 2, 3}<\/p>\n<h3 data-start=\"4479\" data-end=\"4525\">9. Dictionary (dict) \u2013 Key-Value Pairs<\/h3>\n<p><span data-state=\"closed\">student = {<\/span>&#8220;name&#8221;: &#8220;John&#8221;, &#8220;age&#8221;: 21}print(type(student))\u00a0 # &lt;class &#8216;dict&#8217;&gt;<\/p>\n<h2>Mutable vs Immutable Data Types in Python<\/h2>\n<figure id=\"attachment_10663\" aria-describedby=\"caption-attachment-10663\" style=\"width: 651px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-10663\" src=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python.webp\" alt=\"data types in python\" width=\"651\" height=\"367\" srcset=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python.webp 1114w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python-300x169.webp 300w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python-1024x578.webp 1024w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python-768x434.webp 768w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python-380x215.webp 380w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Mutable-vs-Immutable-Data-Types-in-Python-800x452.webp 800w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><figcaption id=\"caption-attachment-10663\" class=\"wp-caption-text\">Mutable vs Immutable Data Types in Python<\/figcaption><\/figure>\n<ul>\n<li data-start=\"4676\" data-end=\"4725\"><strong data-start=\"4676\" data-end=\"4687\">Mutable<\/strong> \u2192 can be changed (list, dict, set).<\/li>\n<li data-start=\"4728\" data-end=\"4789\"><strong data-start=\"4728\" data-end=\"4741\">Immutable<\/strong> \u2192 cannot be changed (int, float, str, tuple).<\/li>\n<\/ul>\n<p data-start=\"4791\" data-end=\"4859\">This distinction is crucial for memory management and performance.<\/p>\n<h2>Type Conversion in Python<\/h2>\n<p data-start=\"4901\" data-end=\"4953\">Python lets you convert between data types easily:<\/p>\n<p><span data-state=\"closed\">x = <\/span>&#8220;100&#8221;y = int(x)\u00a0 # Convert string to integerprint(y, type(y))\u00a0 # 100 &lt;class &#8216;int&#8217;&gt;<\/p>\n<h2>Quick Summary Table of Python Data Types<\/h2>\n<table style=\"height: 580px;\" width=\"526\" data-start=\"5114\" data-end=\"5691\">\n<thead data-start=\"5114\" data-end=\"5168\">\n<tr data-start=\"5114\" data-end=\"5168\">\n<td><strong>Data Type<\/strong><\/td>\n<td><strong>Example<\/strong><\/td>\n<td><strong>Mutable\/Immutable<\/strong><\/td>\n<td><strong>Use Case<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr data-start=\"5223\" data-end=\"5281\">\n<td data-start=\"5223\" data-end=\"5235\" data-col-size=\"sm\">int<\/td>\n<td data-start=\"5235\" data-end=\"5245\" data-col-size=\"sm\">10<\/td>\n<td data-start=\"5245\" data-end=\"5264\" data-col-size=\"sm\">Immutable<\/td>\n<td data-start=\"5264\" data-end=\"5281\" data-col-size=\"sm\">Counting, IDs<\/td>\n<\/tr>\n<tr data-start=\"5282\" data-end=\"5342\">\n<td data-start=\"5282\" data-end=\"5294\" data-col-size=\"sm\">float<\/td>\n<td data-start=\"5294\" data-end=\"5304\" data-col-size=\"sm\">3.14<\/td>\n<td data-start=\"5304\" data-end=\"5323\" data-col-size=\"sm\">Immutable<\/td>\n<td data-start=\"5323\" data-end=\"5342\" data-col-size=\"sm\">Scientific calc<\/td>\n<\/tr>\n<tr data-start=\"5343\" data-end=\"5400\">\n<td data-start=\"5343\" data-end=\"5355\" data-col-size=\"sm\">str<\/td>\n<td data-start=\"5355\" data-end=\"5365\" data-col-size=\"sm\">&#8220;Hello&#8221;<\/td>\n<td data-start=\"5365\" data-end=\"5384\" data-col-size=\"sm\">Immutable<\/td>\n<td data-start=\"5384\" data-end=\"5400\" data-col-size=\"sm\">Text storage<\/td>\n<\/tr>\n<tr data-start=\"5401\" data-end=\"5456\">\n<td data-start=\"5401\" data-end=\"5413\" data-col-size=\"sm\">bool<\/td>\n<td data-start=\"5413\" data-end=\"5423\" data-col-size=\"sm\">True<\/td>\n<td data-start=\"5423\" data-end=\"5442\" data-col-size=\"sm\">Immutable<\/td>\n<td data-start=\"5442\" data-end=\"5456\" data-col-size=\"sm\">Conditions<\/td>\n<\/tr>\n<tr data-start=\"5457\" data-end=\"5513\">\n<td data-start=\"5457\" data-end=\"5469\" data-col-size=\"sm\">list<\/td>\n<td data-start=\"5469\" data-end=\"5479\" data-col-size=\"sm\">[1,2,3]<\/td>\n<td data-start=\"5479\" data-end=\"5498\" data-col-size=\"sm\">Mutable<\/td>\n<td data-start=\"5498\" data-end=\"5513\" data-col-size=\"sm\">Collections<\/td>\n<\/tr>\n<tr data-start=\"5514\" data-end=\"5569\">\n<td data-start=\"5514\" data-end=\"5526\" data-col-size=\"sm\">tuple<\/td>\n<td data-start=\"5526\" data-end=\"5536\" data-col-size=\"sm\">(1,2,3)<\/td>\n<td data-start=\"5536\" data-end=\"5555\" data-col-size=\"sm\">Immutable<\/td>\n<td data-start=\"5555\" data-end=\"5569\" data-col-size=\"sm\">Fixed data<\/td>\n<\/tr>\n<tr data-start=\"5570\" data-end=\"5628\">\n<td data-start=\"5570\" data-end=\"5582\" data-col-size=\"sm\">set<\/td>\n<td data-start=\"5582\" data-end=\"5592\" data-col-size=\"sm\">{1,2,3}<\/td>\n<td data-start=\"5592\" data-end=\"5611\" data-col-size=\"sm\">Mutable<\/td>\n<td data-start=\"5611\" data-end=\"5628\" data-col-size=\"sm\">Unique values<\/td>\n<\/tr>\n<tr data-start=\"5629\" data-end=\"5691\">\n<td data-start=\"5629\" data-end=\"5641\" data-col-size=\"sm\">dict<\/td>\n<td data-start=\"5641\" data-end=\"5651\" data-col-size=\"sm\">{&#8220;a&#8221;:1}<\/td>\n<td data-start=\"5651\" data-end=\"5670\" data-col-size=\"sm\">Mutable<\/td>\n<td data-start=\"5670\" data-end=\"5691\" data-col-size=\"sm\">Key-value storage<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Real-World Applications of Python Data Types<\/h2>\n<figure id=\"attachment_10666\" aria-describedby=\"caption-attachment-10666\" style=\"width: 773px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-10666\" src=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types.webp\" alt=\"type of data in python\" width=\"773\" height=\"515\" srcset=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types.webp 1536w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-300x200.webp 300w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-1024x683.webp 1024w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-768x512.webp 768w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-380x253.webp 380w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-800x533.webp 800w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2025\/08\/Real-World-Applications-of-Python-Data-Types-1160x773.webp 1160w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><figcaption id=\"caption-attachment-10666\" class=\"wp-caption-text\">Real-World Applications of Python Data Types<\/figcaption><\/figure>\n<ul>\n<li data-start=\"5754\" data-end=\"5829\"><strong data-start=\"5754\" data-end=\"5775\">Integers &amp; Floats<\/strong> \u2192 Banking systems, statistics, and AI calculations.<\/li>\n<li data-start=\"5832\" data-end=\"5886\"><strong data-start=\"5832\" data-end=\"5843\">Strings<\/strong> \u2192 Chatbots, NLP, and data entry systems.<\/li>\n<li data-start=\"5889\" data-end=\"5949\"><strong data-start=\"5889\" data-end=\"5907\">Lists &amp; Tuples<\/strong> \u2192 Storing datasets in Machine Learning.<\/li>\n<li data-start=\"5952\" data-end=\"6009\"><strong data-start=\"5952\" data-end=\"5968\">Dictionaries<\/strong> \u2192 JSON, APIs, and configuration files.<\/li>\n<li data-start=\"6012\" data-end=\"6063\"><strong data-start=\"6012\" data-end=\"6020\">Sets<\/strong> \u2192 Removing duplicates in large datasets.<\/li>\n<\/ul>\n<h2>FAQs on Data Types in Python<\/h2>\n<p><strong>Q1. How many types of data exist in Python?<\/strong><\/p>\n<p>There are 9 standard built-in types in Python. They are: int, float, complex, str, bool, list, tuple, set, dict.<\/p>\n<p><strong>Q2. What is the difference between a list and a tuple?<\/strong><\/p>\n<p>A list is mutable while a tuple is immutable.<\/p>\n<p><strong>Q3. What is the meaning of mutable and immutable types in Python?<\/strong><\/p>\n<p>Mutable types can be changed (lists, sets, dicts) while immutable types cannot be changed (int, float, str, tuple).<\/p>\n<h2>Conclusion<\/h2>\n<p data-start=\"6588\" data-end=\"6849\">Becoming familiar with <strong>data types in Python<\/strong> is the first step to becoming a confident Python programmer. There are many different kinds of data types, so even if you do not have any intention of implementing collection data types like lists and dictionaries right away, it is still good to know they exist.<\/p>\n<p>If you are a beginner, create some experiments with each type, try type conversions, and write simple programs. Once you fully understand the basic data types in Python, you will feel more comfortable moving onto bigger concepts like functions, OOP, and data structures.<\/p>\n<p>If you really want to build a solid foundation, look to take a <strong>Python course<\/strong> online or in your local community. Online courses often offer comprehensive training to help you understand <strong>data types in Python<\/strong>, but they also provide insight into real-world projects, best practices, and advanced topics.<\/p>\n<h2>Related Links<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.kaashivinfotech.com\/blog\/types-of-data-classification-examples-uses\/\">Types of Data in Data Science 5 Must Know Explained Simply<\/a><\/li>\n<li><a href=\"https:\/\/www.kaashivinfotech.com\/blog\/visualization-of-data-types-tools-examples\/\">7 Eye-Opening Insights About Visualization of Data: Types, Tools &amp; Real Examples<\/a><\/li>\n<li><a href=\"https:\/\/www.wikitechy.com\/python-programming-languages-beginners-guide\/\" target=\"_blank\" rel=\"noopener\">Python Programming Languages: Everything You Need to Know to Get Started<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Why Learn Data Types in Python? Back when I was first learning how to code in Python, one of the hardest topics for me to grasp was data types in Python. All programming languages have their own syntax to work with numbers, text, and collections, and Python is no different. Defining which data type [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":10659,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3236],"tags":[8601,8606,1257,8604,1250,8605,8607,8603,8602],"class_list":["post-10652","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-data-types-in-python","tag-mutable-vs-immutable-python","tag-python-basics","tag-python-built-in-types","tag-python-course","tag-python-data-structures","tag-python-programming-2025","tag-python-variables","tag-type-of-data-in-python"],"_links":{"self":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/10652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/comments?post=10652"}],"version-history":[{"count":0,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/10652\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/media\/10659"}],"wp:attachment":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/media?parent=10652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/categories?post=10652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/tags?post=10652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}