{"id":31691,"date":"2024-11-01T09:01:47","date_gmt":"2024-11-01T09:01:47","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31691"},"modified":"2024-11-01T12:31:25","modified_gmt":"2024-11-01T12:31:25","slug":"02%ec%9e%a5-basics-of-python-programming-data-types","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31691\/","title":{"rendered":"02: Basics of Python Programming &#8211; Data Types"},"content":{"rendered":"<h1>Chapter 02: Basics of Python Programming &#8211; Data Types<\/h1>\n<p>In programming, data types help to indicate what kind of value each piece of data holds. Python offers a variety of built-in data types, and understanding and using them correctly is essential for writing efficient and error-free code. In this chapter, we will delve deeply into Python&#8217;s main data types and their usage.<\/p>\n<h2>Main Data Types in Python<\/h2>\n<p>Python&#8217;s data types can be broadly classified into boolean (<code>bool<\/code>), integer (<code>int<\/code>), floating-point (<code>float<\/code>), complex (<code>complex<\/code>), string (<code>str<\/code>), list (<code>list<\/code>), tuple (<code>tuple<\/code>), set (<code>set<\/code>), and dictionary (<code>dict<\/code>).<\/p>\n<h3>Boolean Type (<code>bool<\/code>)<\/h3>\n<p>The boolean type represents logical true (<code>True<\/code>) and false (<code>False<\/code>). It is mainly used in conditional statements and is also employed in logical operations.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>is_raining = True\nis_sunny = False\nprint(is_raining and is_sunny)  # Output: False\nprint(is_raining or is_sunny)   # Output: True\n<\/code><\/pre>\n<\/div>\n<h3>Integer Type (<code>int<\/code>)<\/h3>\n<p>The integer type represents whole numbers. Python supports arbitrary precision, so there is no limit on the number of digits in an integer as long as memory allows.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>large_number = 10000000000000000000\nsmall_number = -42\nprint(large_number + small_number)  # Output: 9999999999999999958\n<\/code><\/pre>\n<\/div>\n<h3>Floating-Point Type (<code>float<\/code>)<\/h3>\n<p>The floating-point type is used to represent numbers with decimal points (real numbers). The accuracy of floating-point numbers may vary slightly based on the binary representation used by the system.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>pi = 3.141592653589793\nradius = 5.0\narea = pi * (radius ** 2)\nprint(\"Area of the circle:\", area)  # Output: Area of the circle: 78.53981633974483\n<\/code><\/pre>\n<\/div>\n<h3>Complex Type (<code>complex<\/code>)<\/h3>\n<p>The complex type is used to represent complex numbers composed of a real part and an imaginary part. Complex numbers are primarily used in scientific calculations or engineering mathematics.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>z = 3 + 4j\nprint(\"Real part:\", z.real)  # Output: Real part: 3.0\nprint(\"Imaginary part:\", z.imag)  # Output: Imaginary part: 4.0\n<\/code><\/pre>\n<\/div>\n<h3>String Type (<code>str<\/code>)<\/h3>\n<p>String represents text and is enclosed in single or double quotes. Strings are immutable data types.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>greeting = \"Hello, World!\"\nname = 'Alice'\nmessage = greeting + \" \" + name\nprint(message)  # Output: Hello, World! Alice\n<\/code><\/pre>\n<\/div>\n<h3>List Type (<code>list<\/code>)<\/h3>\n<p>A list is a data type that can store multiple values in order and is defined with square brackets ([]). Lists are mutable data types, allowing for the addition, deletion, and modification of elements.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>fruits = [\"apple\", \"banana\", \"cherry\"]\nfruits.append(\"orange\")\nprint(fruits)  # Output: ['apple', 'banana', 'cherry', 'orange']\nfruits[1] = \"blueberry\"\nprint(fruits)  # Output: ['apple', 'blueberry', 'cherry', 'orange']\n<\/code><\/pre>\n<\/div>\n<h3>Tuple Type (<code>tuple<\/code>)<\/h3>\n<p>A tuple is similar to a list, but it has immutable characteristics. It is useful for managing objects that should not change. Tuples are defined with parentheses ().<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>coordinates = (10.0, 20.0)\n# coordinates[0] = 15.0 # Error: 'tuple' object does not support item assignment\nprint(coordinates)  # Output: (10.0, 20.0)\n<\/code><\/pre>\n<\/div>\n<h3>Set Type (<code>set<\/code>)<\/h3>\n<p>A set is a collection of unique elements with no defined order. It is useful for performing set-related operations. Sets are defined with curly braces ({}).<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>fruit_set = {\"apple\", \"banana\", \"cherry\"}\nfruit_set.add(\"orange\")\nprint(fruit_set)  # Output's order is random: {'orange', 'banana', 'cherry', 'apple'}\n\n# Example of removing an element\nfruit_set.remove(\"banana\")\nprint(fruit_set)  # Output: {'orange', 'cherry', 'apple'}\n<\/code><\/pre>\n<\/div>\n<h3>Dictionary Type (<code>dict<\/code>)<\/h3>\n<p>A dictionary is a data type for storing key\/value pairs. It is defined with curly braces ({}), and keys must be unique.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>person = {\"name\": \"John\", \"age\": 30, \"job\": \"developer\"}\nprint(person[\"name\"])  # Output: John\n\n# Adding a new key\/value pair\nperson[\"city\"] = \"New York\"\nprint(person)  # Output: {'name': 'John', 'age': 30, 'job': 'developer', 'city': 'New York'}\n<\/code><\/pre>\n<\/div>\n<h2>Type Conversion<\/h2>\n<p>Converting data types in Python is very useful. It mainly occurs through explicit conversion or implicit conversion.<\/p>\n<h3>Explicit Conversion (Type Conversion)<\/h3>\n<p>Explicit conversion is done by the developer explicitly stating the conversion in the code. Python provides various functions for type conversion.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code># Converting an integer to a string\nnum = 123\nnum_str = str(num)\nprint(type(num_str))  # Output: <class 'str'>\n\n# Converting a string to an integer\nstr_num = \"456\"\nnum_int = int(str_num)\nprint(type(num_int))  # Output: <class 'int'>\n\n# Converting an integer to a floating-point number\nint_num = 10\nfloat_num = float(int_num)\nprint(float_num)  # Output: 10.0\n<\/code><\/pre>\n<\/div>\n<h3>Implicit Conversion (Automatic Type Conversion)<\/h3>\n<p>Implicit conversion refers to type conversion that is automatically carried out by Python. It mainly occurs when there is no risk of data loss.<\/p>\n<div class=\"example\">\n<h4>Example<\/h4>\n<pre><code>int_num = 5\nfloat_num = 2.3\nresult = int_num + float_num\nprint(result)  # Output: 7.3\nprint(type(result))  # Output: <class 'float'>\n<\/code><\/pre>\n<\/div>\n<h2>Conclusion<\/h2>\n<p>In this chapter, we learned about the various data types in Python. Understanding the characteristics and proper usage of each data type is very important for gaining a deeper understanding of Python programming. In the next chapter, we will cover more advanced topics such as control statements and functions, which will help you write more complex and powerful programs using Python.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chapter 02: Basics of Python Programming &#8211; Data Types In programming, data types help to indicate what kind of value each piece of data holds. Python offers a variety of built-in data types, and understanding and using them correctly is essential for writing efficient and error-free code. In this chapter, we will delve deeply into &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31691\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;02: Basics of Python Programming &#8211; Data Types&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[98],"tags":[95],"class_list":["post-31691","post","type-post","status-publish","format-standard","hentry","category--en","tag--en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/31691\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Chapter 02: Basics of Python Programming &#8211; Data Types In programming, data types help to indicate what kind of value each piece of data holds. Python offers a variety of built-in data types, and understanding and using them correctly is essential for writing efficient and error-free code. In this chapter, we will delve deeply into &hellip; \ub354 \ubcf4\uae30 &quot;02: Basics of Python Programming &#8211; Data Types&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31691\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:01:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T12:31:25+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"02: Basics of Python Programming &#8211; Data Types\",\"datePublished\":\"2024-11-01T09:01:47+00:00\",\"dateModified\":\"2024-11-01T12:31:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/\"},\"wordCount\":489,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"keywords\":[\"\ud30c\uc774\uc36c\uac15\uc88c\"],\"articleSection\":[\"Python Study\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31691\/\",\"name\":\"02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:01:47+00:00\",\"dateModified\":\"2024-11-01T12:31:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31691\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31691\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"02: Basics of Python Programming &#8211; Data Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/31691\/","og_locale":"ko_KR","og_type":"article","og_title":"02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Chapter 02: Basics of Python Programming &#8211; Data Types In programming, data types help to indicate what kind of value each piece of data holds. Python offers a variety of built-in data types, and understanding and using them correctly is essential for writing efficient and error-free code. In this chapter, we will delve deeply into &hellip; \ub354 \ubcf4\uae30 \"02: Basics of Python Programming &#8211; Data Types\"","og_url":"https:\/\/atmokpo.com\/w\/31691\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:01:47+00:00","article_modified_time":"2024-11-01T12:31:25+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/31691\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31691\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"02: Basics of Python Programming &#8211; Data Types","datePublished":"2024-11-01T09:01:47+00:00","dateModified":"2024-11-01T12:31:25+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31691\/"},"wordCount":489,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"keywords":["\ud30c\uc774\uc36c\uac15\uc88c"],"articleSection":["Python Study"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31691\/","url":"https:\/\/atmokpo.com\/w\/31691\/","name":"02: Basics of Python Programming - Data Types - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:01:47+00:00","dateModified":"2024-11-01T12:31:25+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31691\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31691\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31691\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"02: Basics of Python Programming &#8211; Data Types"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=31691"}],"version-history":[{"count":2,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31691\/revisions"}],"predecessor-version":[{"id":38060,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31691\/revisions\/38060"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}