{"id":70264,"date":"2022-11-02T11:52:43","date_gmt":"2022-11-02T10:52:43","guid":{"rendered":"https:\/\/eiposgrados.com\/?p=70264"},"modified":"2022-12-07T18:44:28","modified_gmt":"2022-12-07T17:44:28","slug":"python-data-types","status":"publish","type":"post","link":"https:\/\/eiposgrados.com\/eng\/python-blog\/python-data-types\/","title":{"rendered":"Python data types"},"content":{"rendered":"<p>Python data types are nothing more than a classification of similar data values. In Python, we do not explicitly declare the data type of a variable. The Python interpreter interprets a value and then automatically assigns it to the appropriate data type<\/p>\n\n\n\n<p>Let&#039;s start...<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-af1a87e8 gb-headline-text\"><strong>Numbers<\/strong><\/h2>\n\n\n\n<p>In Python, there is a Number data type for all operations involving numeric values. This data type can handle all types of numerical values: integers, floating point numbers, and complex numbers.<\/p>\n\n\n\n<p>Numbers are mutable data types, which means that every time we update a variable, a new object with the updated value is created and assigned to the variable.<\/p>\n\n\n\n<p>Numbers are divided into three Python data types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>int \/ Integer<\/strong>: Int can store all integer values. This type of data can be of any size. There is no size limit.<\/li>\n\n\n\n<li><strong>float<\/strong>: he&nbsp;<strong>floating <\/strong>includes all floating point values. There are also no restrictions on the size of a floating point number.<\/li>\n<\/ul>\n\n\n\n<p><strong>complex<\/strong>\u2013 As the name suggests, Python stores numbers in complex form. For example, x + yj, where x is the real part and y is the imaginary part.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"370\" height=\"139\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image.png\" alt=\"Image\" class=\"wp-image-70266\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image.png 370w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-300x113.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-123x46.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-200x75.png 200w\" sizes=\"(max-width: 370px) 100vw, 370px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-0f6a0ad4 gb-headline-text\"><strong>Chains<\/strong><\/h2>\n\n\n\n<p>A&nbsp;<strong>python string<\/strong>&nbsp;It is nothing but a sequence of characters and is therefore also called a character string.<\/p>\n\n\n\n<p>Strings in Python are immutable; the same String instance cannot be modified. Instead, to update the string value, a new updated instance must be provided.<\/p>\n\n\n\n<p>In Python, we declare strings with a sequence of characters between (\u201c\u201d or \u201c\u201d or \u201c\u201d\u201d). For example: \u201cPython\u201d, \u201cLet&#039;s go\u201d, \u201c&#039;This is \u201cPython\u201d.&#039;\u201d.<\/p>\n\n\n\n<p>Additionally, we can use the + operator to concatenate two strings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"421\" height=\"91\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-1.png\" alt=\"Image\" class=\"wp-image-70267\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-1.png 421w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-1-300x65.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-1-123x27.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-1-200x43.png 200w\" sizes=\"(max-width: 421px) 100vw, 421px\" \/><\/figure>\n\n\n\n<h2 class=\"gb-headline gb-headline-ea98aa14 gb-headline-text\"><strong>Booleans<\/strong><\/h2>\n\n\n\n<p>Boolean values in Python include two possible values: True and False<\/p>\n\n\n\n<p>These values are usually used in conditional statements. These two values can be used as operands for logical operations like and , or , not , etc.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"518\" height=\"125\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-2.png\" alt=\"Image\" class=\"wp-image-70268\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-2.png 518w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-2-300x72.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-2-123x30.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-2-200x48.png 200w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/figure>\n\n\n\n<h2 class=\"gb-headline gb-headline-12a22585 gb-headline-text\"><strong>Dictionary<\/strong><\/h2>\n\n\n\n<p>Dictionaries are used to store key-value pairs. He&nbsp;<strong>python dictionary<\/strong>&nbsp;is an ordered collection of data values; However, we can also retrieve the elements in the order in which we inserted them. A dictionary is mutable, which means that we can edit the elements of a dictionary.<\/p>\n\n\n\n<p>The keys in the dictionary must be unique. The key can be any data type as long as the data type is hashable and immutable. The values can be of any data type and can also be modified. We use {} square brackets or the dict() method to create an empty dictionary.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"319\" height=\"146\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-3.png\" alt=\"Image\" class=\"wp-image-70269\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-3.png 319w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-3-300x137.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-3-123x56.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-3-200x92.png 200w\" sizes=\"(max-width: 319px) 100vw, 319px\" \/><\/figure>\n\n\n\n<p><br><\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-6b8e532e gb-headline-text\"><strong>Lists and tuples<\/strong><\/h2>\n\n\n\n<p>Lists and tuples are used to store a sequence of different types of data.<\/p>\n\n\n\n<p>Lists are addressed with [], while tuples are addressed with ().&nbsp;<strong>Python List is mutable<\/strong>&nbsp;while the&nbsp;<strong>tuples<\/strong>&nbsp;They are immutable. Both lists can be accessed through an index.<\/p>\n\n\n\n<p>Lists, once created, can be modified, while tuples cannot be modified. If we try to change a tuple, the Python interpreter throws an error.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"66\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-4.png\" alt=\"Image\" class=\"wp-image-70270\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-4.png 398w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-4-300x50.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-4-123x20.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-4-200x33.png 200w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Sets<\/strong><\/h2>\n\n\n\n<p> <\/p>\n\n\n\n<p>Sets are collections&nbsp;<strong>messy<\/strong>&nbsp;of unique data values. Data values can be of any data type as long as&nbsp;<strong>be hashable<\/strong>&nbsp;and&nbsp;<strong>immutable<\/strong>.<\/p>\n\n\n\n<p>Sets can be initialized with data values separated by a comma and enclosed in braces {}.<\/p>\n\n\n\n<p>Sets ignore all repeating values and only store unique elements. The sets are&nbsp;<strong>mutable<\/strong>, allowing data values to be updated.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"336\" height=\"119\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-5.png\" alt=\"Image\" class=\"wp-image-70271\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-5.png 336w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-5-300x106.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-5-123x44.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/11\/image-5-200x71.png 200w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/figure>\n\n\n\n<p>\u00a1<a href=\"https:\/\/eiposgrados.com\/eng\/programs\/master-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Discover our <strong>Master in Advanced Programming in Python for Big Data, Hacking and Machine Learning<\/strong><\/a>!<\/p>","protected":false},"excerpt":{"rendered":"<p>Python data types are nothing more than a classification of similar data values. In Python, we don&#039;t explicitly declare the data type... <a title=\"Python data types\" class=\"read-more\" href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/python-data-types\/\" aria-label=\"Read more about Python data types\">Read more<\/a><\/p>","protected":false},"author":90,"featured_media":70282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[407],"tags":[],"class_list":["post-70264","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-python"],"acf":[],"_links":{"self":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/70264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/comments?post=70264"}],"version-history":[{"count":0,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/70264\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media\/70282"}],"wp:attachment":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media?parent=70264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/categories?post=70264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/tags?post=70264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}