{"id":93,"date":"2019-01-10T19:18:43","date_gmt":"2019-01-10T19:18:43","guid":{"rendered":"https:\/\/kindsonthegenius.com\/python\/?p=93"},"modified":"2019-03-31T21:07:59","modified_gmt":"2019-03-31T21:07:59","slug":"04-python-data-types","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/","title":{"rendered":"Python &#8211; Data Types"},"content":{"rendered":"\r\n<p>The Python programming language provides a set of data types that can be used to define a variable. Memory is allocated for a variable based on the data type of the variable. This is because, data types have different sizes which is in bytes.<\/p>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Variable Declaration<\/h4>\r\n\r\n\r\n\r\n<p>Python does not provide an explicit way to declare a variable. It uses implicit variable declaration. For instance in language like Java, you must declare a variable before you can assign it a value.<\/p>\r\n\r\n\r\n\r\n<p>In Python, the variable declaration is done automatically when a variable is assigned a value using the assignment operator (=). The examples below show variable assignment (with implicit declaration).<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code># Assignment and implicit data type declaration in Python\r\nindex = 10              # An integer data type\r\ndistance = 500.05       # A floating point data type\r\nfirstname = \"Kindson\"   # A string data\r\nscores = [67,87,98,54,82] # A list data type\r\n\r\nprint(index)\r\nprint(distance)\r\nprint(firstname)<\/code><\/pre>\r\n\r\n\r\n\r\n<p>In the above program, index is an integer type, distance is a floating point type while firstname is a string type. If you run the above code, you will have :<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>10 \r\n500.05 \r\nKindson<\/code><\/pre>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Multiple Assignments<\/h4>\r\n\r\n\r\n\r\n<p>A unique feature of Python is that it allows you to assign a value to more than one variable in the same line. This is accomplished using the code below:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>x = y = z = 200\r\nscore = average = 89.9<\/code><\/pre>\r\n\r\n\r\n\r\n<p>In the first line three assignments was made. 200 is assigned to x, assigned to y, and assigned to z. This is equivalent to :<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>x = 200\r\ny = 200\r\nz = 200<\/code><\/pre>\r\n\r\n\r\n\r\n<p>In the second line score is assigned a value of 89.9 and average is assigned a value of 89.9 as well<\/p>\r\n\r\n\r\n\r\n<p>Another way to achieve multiple assignment is to assign different values to different variables in the same. For the example below, name is assigned a value Kindson, score is assigned a value of 100 and age is assigned a value 36<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>name, score, age = \"Kindson\", 100, 36<\/code><\/pre>\r\n\r\n\r\n\r\n<p>You simply use comma to separate the variable names and the values and then the variables are assigned receptively.<\/p>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Python Standard Data Types<\/h4>\r\n\r\n\r\n\r\n<p>The Python Programming Language provided inbuilt data types which a have standard memory size associated with them. The 5 Python standard data types we are going to consider includes:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Numbers<\/li>\r\n<li>String<\/li>\r\n<li>Lists<\/li>\r\n<li>Tuples<\/li>\r\n<li>Dictionary<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p><strong>Numbers in Python<\/strong><\/p>\r\n\r\n\r\n\r\n<p>Numbers are data types used to store numeric values. To use a number data type simply assign a number to the variable.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>score = 89.4\r\ntotal = 200<\/code><\/pre>\r\n\r\n\r\n\r\n<p>The above code create two number variables, score and total and assigns them values<\/p>\r\n\r\n\r\n\r\n<p>Python provides a function to delete reference to a number variable that has been created. This is done using del keyword. For example:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>del score\r\ndel total\r\ndel x, y, z<\/code><\/pre>\r\n\r\n\r\n\r\n<p>The four different number types provided by Python are:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>int &#8211; signed or unsigned integer values<\/li>\r\n<li>long &#8211; long integers<\/li>\r\n<li>float &#8211; floating point values<\/li>\r\n<li>complex &#8211; complex numbers having a real and imaginary parts<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The table below give a summary of<\/p>\r\n\r\n\r\n\r\n<table class=\"wp-block-table is-style-stripes\">\r\n<tbody>\r\n<tr>\r\n<th>int<\/th>\r\n<th>long<\/th>\r\n<th>float<\/th>\r\n<th>complex<\/th>\r\n<\/tr>\r\n<tr>\r\n<td>300<\/td>\r\n<td>8976576L<\/td>\r\n<td>0.45<\/td>\r\n<td>5.56j<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>55<\/td>\r\n<td>-0x29656L<\/td>\r\n<td>45.20<\/td>\r\n<td>63.j<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>-524<\/td>\r\n<td>055L<\/td>\r\n<td>-52.8<\/td>\r\n<td>5.087e-24j<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Python Strings<\/h4>\r\n\r\n\r\n\r\n<p>In Python, strings are identified as a set of characters enclosed in quotes, which may be either single or double quotes. Substrings of a particular string can be formed using the slice operator [ ] and [:].<\/p>\r\n\r\n\r\n\r\n<p>A substring is specified with index staring from 0 for the first character of the string. A index of -1 is also used to indicate the last character on the string.<\/p>\r\n\r\n\r\n\r\n<p>Two strings can be joined together using the concatenation operator (+). Strings can be repeted or multiplied using the repetition operator (*). Lets take some examples:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>word = \"Python Programming\"\r\nprint(word)              # Prints out the entire string\r\nprint(word[0])           # Prints the first character in the string\r\nprint(word[3:6])         # Print the 4th to the 7th character\r\nprint(word[3:]           # Prints the 4th to the last character\r\nprint(word + \" Tutorial\" # Attaches Tutorial to the end of the string\r\nprint(word * 3)          # Prints the string 3 times<\/code><\/pre>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<p>Python Lists<\/p>\r\n\r\n\r\n\r\n<p>Lists are part of Python collection data types. A list in Python contains different values separated by comma and enclosed in square braces []. Items in a list could be of the same or of different data types.<\/p>\r\n\r\n\r\n\r\n<p>Just like in strings, individual elements of a list can be accessed using the slice operator [ ] or [ ]. Starting from the first element of the list, the index is 0. Starting from the last element, the index is -1.<\/p>\r\n\r\n\r\n\r\n<p>The concatenation operator (+) and the repetition operator (*) applies in list just like in strings. The program code below illustrates the use of lists in Python.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>list1= [ 'wxyz', 0.85, 52, '100', 780.2 ]\r\nlist2 = [999, 'Kindson']\r\n\r\nprint(list1)         # Prints whole list\r\nprint(list1[0])      # Prints first item in of the list\r\nprint(list1[1:4])     # Prints elements beginning from 2nd till 5th \r\nprint(list1[2:])     # Prints elements beginning from 3rd element\r\nprint(list2 * 2)      # Prints list twice\r\nprint(list1 + list2)  # Combines bot list1 and list2<\/code><\/pre>\r\n\r\n\r\n\r\n<p>If the above code is executed, the output would be:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>[ 'wxyz', 0.85, 52, '100', 780.2 ]\r\nwxyz\r\n[0.85, 52, '100', 780.2]\r\n[52, '100', 780.2]\r\n[999, 'Kindson'999, 'Kindson']\r\n['wxyz', 0.85, 52, '100', 780.2, 999, 'Kindson' ]<\/code><\/pre>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Python Tuples<\/h4>\r\n\r\n\r\n\r\n<p>Tuples in Python are similar to lists with the following two difference:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Tuples are specified using rounded brackets (). Not square braces!.<\/li>\r\n<li>Tuples are immutable &#8211; this means that items in a tuple cannot be modified.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Let&#8217;s take some examples<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>tuple1= ( 'wxyz', 0.85, 52, '100', 780.2 )\r\ntuple2= (999, 'Kindson')<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Every other operations that apply to a list applies to a tuple. But take not that the operations below would succeed in a list but would generate an error in a tuple.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>list1[0] = 'abcd'      # Would succeed because lists a mutable\r\ntuple1[0] = 'abcd'     # The would fail because tuples are immutable<\/code><\/pre>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Python Dictionary<\/h4>\r\n\r\n\r\n\r\n<p>Python Dictionary are used to store key value pairs just like in a hash table. Each entry in a dictionary has a key and a value. Keys and values in a dictionary can be of any type.<\/p>\r\n\r\n\r\n\r\n<p>A typical example of a dictionary in Python is the days of the week where each week day is assigned a number each corresponding to the day name. This is shown below<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>weekdays = {\r\n1: \"Monday\",\r\n2: \"Tuesday\",\r\n3: \"Wednesday\",\r\n4: \"Thursday\",\r\n5: \"Friday\",\r\n6: \"Saturday\",\r\n7: \"Sunday\"\r\n}<\/code><\/pre>\r\n\r\n\r\n\r\n<p>The following operations are all valid for a dictionary in Python:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>print(weekdays[1])       # Prints Monday\r\nprint(weekdays)          # Prints the complete dictionary\r\nprint(weekdays.keys())   # Prints all the keys, 1, 2, 3,4,5,6,7\r\nprint(weekdays.values()) # Prints all the values: Monday, . . , Sunday<\/code><\/pre>\r\n\r\n\r\n<hr \/>\r\n\r\n\r\n<h4 class=\"wp-block-heading\">Data Type Conversion in Python<\/h4>\r\n\r\n\r\n\r\n<p>Python provides functions needed to convert between the data types. For example, you may want to covert a user input in string to an integer to be able to use it for calculation. The table below gives a list of Python data type conversion functions<\/p>\r\n\r\n\r\n\r\n<table class=\"wp-block-table is-style-stripes\">\r\n<tbody>\r\n<tr>\r\n<th>S#<\/th>\r\n<th>Function and Description<\/th>\r\n<\/tr>\r\n<tr>\r\n<td>1<\/td>\r\n<td><strong>int(x [,base])<\/strong>Converts x to an integer. Base specifies the base if x is a string.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>2<\/td>\r\n<td><strong>long(x [,base] )<\/strong> -Converts x to a long integer. Base specifies the base if x is a string.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td><strong>float(x)<\/strong>Converts x to a floating-point number.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>4<\/td>\r\n<td><strong>complex(real [,imag])<\/strong>&#8211; Creates a complex number.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>5<\/td>\r\n<td><strong>str(x)\u00a0&#8211;<\/strong>Converts object x to a string representation.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>6<\/td>\r\n<td><strong>repr(x)\u00a0&#8211;<\/strong>Converts object x to an expression string.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>7<\/td>\r\n<td><strong>eval(str)\u00a0&#8211;<\/strong>Evaluates a string and returns an object.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>8<\/td>\r\n<td><strong>tuple(s)\u00a0&#8211;<\/strong>Converts s to a tuple.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>9<\/td>\r\n<td><strong>list(s)\u00a0&#8211;<\/strong>Converts s to a list.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>10<\/td>\r\n<td><strong>set(s)\u00a0&#8211;<\/strong>Converts s to a set.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>11<\/td>\r\n<td><strong>dict(d)\u00a0&#8211;\u00a0<\/strong>Creates a dictionary. d need to be a sequence of (key,value) tuples.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>12<\/td>\r\n<td><strong>frozenset(s)\u00a0&#8211;<\/strong>Converts s to a frozen set.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>13<\/td>\r\n<td><strong>chr(x)\u00a0&#8211;\u00a0<\/strong>Converts an integer type to a character type.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>14<\/td>\r\n<td><strong>unichr(x)\u00a0&#8211;\u00a0<\/strong>Converts an integer type to a Unicode character.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>15<\/td>\r\n<td><strong>ord(x)\u00a0&#8211;\u00a0<\/strong>Converts a single character type to its integer value.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>16<\/td>\r\n<td><strong>hex(x)\u00a0&#8211;\u00a0<\/strong>Converts an integer type to a hexadecimal string.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>17<\/td>\r\n<td><strong>oct(x)\u00a0&#8211;\u00a0<\/strong>Converts an integer type to an octal string.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n","protected":false},"excerpt":{"rendered":"<p>The Python programming language provides a set of data types that can be used to define a variable. Memory is allocated for a variable based &hellip; <\/p>\n","protected":false},"author":395,"featured_media":287,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-93","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python - Data Types - Python Tutorials<\/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:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python - Data Types - Python Tutorials\" \/>\n<meta property=\"og:description\" content=\"The Python programming language provides a set of data types that can be used to define a variable. Memory is allocated for a variable based &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-10T19:18:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-31T21:07:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"887\" \/>\n\t<meta property=\"og:image:height\" content=\"494\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Python &#8211; Data Types\",\"datePublished\":\"2019-01-10T19:18:43+00:00\",\"dateModified\":\"2019-03-31T21:07:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/\"},\"wordCount\":1022,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/01\\\/Data-Types-in-Python-.jpg\",\"articleSection\":[\"Python Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/\",\"name\":\"Python - Data Types - Python Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/01\\\/Data-Types-in-Python-.jpg\",\"datePublished\":\"2019-01-10T19:18:43+00:00\",\"dateModified\":\"2019-03-31T21:07:59+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/01\\\/Data-Types-in-Python-.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/01\\\/Data-Types-in-Python-.jpg\",\"width\":887,\"height\":494,\"caption\":\"Data Types in Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/04-python-data-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python &#8211; Data Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\",\"name\":\"Python Tutorials\",\"description\":\"Python Tutorial for Programming and Data Science\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python - Data Types - Python Tutorials","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:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/","og_locale":"en_US","og_type":"article","og_title":"Python - Data Types - Python Tutorials","og_description":"The Python programming language provides a set of data types that can be used to define a variable. Memory is allocated for a variable based &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/","og_site_name":"Python Tutorials","article_published_time":"2019-01-10T19:18:43+00:00","article_modified_time":"2019-03-31T21:07:59+00:00","og_image":[{"width":887,"height":494,"url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Python &#8211; Data Types","datePublished":"2019-01-10T19:18:43+00:00","dateModified":"2019-03-31T21:07:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/"},"wordCount":1022,"commentCount":1,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg","articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/","url":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/","name":"Python - Data Types - Python Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg","datePublished":"2019-01-10T19:18:43+00:00","dateModified":"2019-03-31T21:07:59+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/01\/Data-Types-in-Python-.jpg","width":887,"height":494,"caption":"Data Types in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/python\/04-python-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/python\/"},{"@type":"ListItem","position":2,"name":"Python &#8211; Data Types"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/python\/#website","url":"https:\/\/www.kindsonthegenius.com\/python\/","name":"Python Tutorials","description":"Python Tutorial for Programming and Data Science","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/python\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":2,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/93\/revisions\/266"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media\/287"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}