<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4694,"date":"2022-08-16T10:21:41","date_gmt":"2022-08-16T10:21:41","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4694"},"modified":"2022-08-16T10:22:06","modified_gmt":"2022-08-16T10:22:06","slug":"what-is-tuple-in-python","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/","title":{"rendered":"What is Tuple in python ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">In python Tuple is used to store the sequence of immutable Python objects.<\/li>\n<li style=\"text-align: justify;\">It is similar to lists since the value of the items stored in the list can be changed.<\/li>\n<li style=\"text-align: justify;\">If the tuple is immutable then the value of the items stored in the tuple cannot be changed.<\/li>\n<li style=\"text-align: justify;\">It can be written as the collection of comma-separated (,) values enclosed with the small () brackets.<\/li>\n<li style=\"text-align: justify;\">The parentheses are optional but it is good practice to use.<\/li>\n<li style=\"text-align: justify;\">A tuple is indexed in the same way as the lists then items in the tuples can be accessed by using their specific index value.<\/li>\n<li style=\"text-align: justify;\">Using negative indexing tuple element can also access then index of -1 denotes the rightmost element and -2 to the second last item and so on.<\/li>\n<li style=\"text-align: justify;\">The tuple items cannot be deleted by using the\u00a0<strong>del<\/strong>keyword as tuples are immutable, unlike lists.<\/li>\n<li style=\"text-align: justify;\">We can use del keyword with the tuple name, to delete an entire tuple.<\/li>\n<li style=\"text-align: justify;\">Concatenation (+), Membership (in), repetition (*) are the operators works in the same way as they work with the list.<\/li>\n<li style=\"text-align: justify;\">Using tuple instead of list gives us a clear idea that tuple data is constant and must not be changed.<\/li>\n<li style=\"text-align: justify;\">It can simulate a dictionary without keys and it can be used a dictionary which is consider the following nested structure.<\/li>\n<\/ul>\n<h3 id=\"sample-code\" style=\"text-align: justify;\"><strong>Sample Code<\/strong><\/h3>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-python code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-python code-embed-code\">tup1 = (&quot;Wikitechy&quot;) <br\/>        print(type(tup1))  <br\/>        #Creating a tuple with single element   <br\/><br\/>tup2 = (&quot;Wikitechy&quot;,)  <br\/><br\/>print(type(tup2))  <\/code><\/pre> <\/div>\n<h3 id=\"output\" style=\"text-align: justify;\"><strong>Output<\/strong><\/h3>\n<p style=\"text-align: justify;\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4695\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png\" alt=\"\" width=\"1487\" height=\"260\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png 1487w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-300x52.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-1024x179.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-768x134.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-390x68.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-820x143.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function-1180x206.png 1180w\" sizes=\"(max-width: 1487px) 100vw, 1487px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In python Tuple is used to store the sequence of immutable Python objects. It is similar to lists since the value of the items stored in the list can be changed. If the tuple is immutable then the value of the items stored in the tuple cannot be changed. It can be written as the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[5608],"tags":[18166,18169,18170,18167,18165,18171,18172,18168,18179,18176,18175,18177,18173,18174,18178],"class_list":["post-4694","post","type-post","status-publish","format-standard","hentry","category-python","tag-list-vs-tuple-in-python","tag-python-tuple-append","tag-python-tuple-index","tag-tuple-example","tag-tuple-in-python-example","tag-tuple-is-mutable-or-immutable","tag-tuple-pronunciation","tag-tuple-vs-list","tag-what-is-a-tuple-object-in-python-what-is-named-tuple-in-python-what-is-the-difference-between-list-tuple-and-set-in-python","tag-what-is-difference-between-list-and-tuple-in-python","tag-what-is-list-and-tuple-in-python","tag-what-is-list-tuple-and-dictionary-in-python","tag-what-is-tuple-in-python","tag-what-is-tuple-in-python-3","tag-what-is-tuple-unpacking-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy<\/title>\n<meta name=\"description\" content=\"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.\" \/>\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.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-16T10:21:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-16T10:22:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/\",\"name\":\"What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png\",\"datePublished\":\"2022-08-16T10:21:41+00:00\",\"dateModified\":\"2022-08-16T10:22:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png\",\"width\":1487,\"height\":260},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy","description":"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.","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.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/","og_locale":"en_US","og_type":"article","og_title":"What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy","og_description":"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/","og_site_name":"Wikitechy","article_published_time":"2022-08-16T10:21:41+00:00","article_modified_time":"2022-08-16T10:22:06+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/","name":"What is Tuple in python ? - Python Tuples - Tuples in Python - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png","datePublished":"2022-08-16T10:21:41+00:00","dateModified":"2022-08-16T10:22:06+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is Tuple in python ? - In python Tuple is used to store the sequence of immutable Python objects.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-tuple-in-python\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/tuple-function.png","width":1487,"height":260},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4694"}],"version-history":[{"count":2,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4694\/revisions"}],"predecessor-version":[{"id":4697,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4694\/revisions\/4697"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}