{"id":257056,"date":"2025-07-16T17:06:57","date_gmt":"2025-07-16T17:06:57","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=257056"},"modified":"2025-07-16T17:10:09","modified_gmt":"2025-07-16T17:10:09","slug":"which-following-is-a-tuple","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2025\/07\/16\/which-following-is-a-tuple\/","title":{"rendered":"Which following is a tuple"},"content":{"rendered":"\n<p>Which following is a tuple? A. [6, 5, 4] B. (2) C. 7 D. {3, 2, 1}<\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-6-color\">The correct answer and explanation is:<\/mark><\/strong><\/p>\n\n\n\n<p>The correct answer is <strong>B. (2)<\/strong>.<\/p>\n\n\n\n<p>A tuple in Python is an immutable ordered collection of elements. Tuples are typically enclosed in parentheses <code>()<\/code>, and they can store multiple items, just like lists. However, there is a significant difference between a list and a tuple: <strong>tuples are immutable<\/strong>, meaning once created, their elements cannot be changed, added, or removed.<\/p>\n\n\n\n<p>To better understand why <strong>B<\/strong> is a tuple, consider the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>A. [6, 5, 4]<\/strong>: This is a list because it is enclosed in square brackets <code>[]<\/code>. Lists are mutable, meaning you can add, remove, or change the elements of a list after its creation.<\/li>\n\n\n\n<li><strong>B. (2)<\/strong>: This appears to be a tuple, but in reality, this is <strong>not a tuple<\/strong>. In Python, a single element in parentheses does not automatically create a tuple. To define a tuple with a single element, you need to have a trailing comma, like this: <code>(2,)<\/code>. Without the comma, Python treats it as just a regular expression for grouping.<\/li>\n\n\n\n<li><strong>C. 7<\/strong>: This is simply an integer, not a tuple. A tuple can only be created using multiple elements or a single element enclosed in parentheses with a comma.<\/li>\n\n\n\n<li><strong>D. {3, 2, 1}<\/strong>: This is a set, not a tuple. Sets are unordered collections of unique elements enclosed in curly braces <code>{}<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Therefore, a tuple is best represented by an ordered collection of elements in parentheses. If you want to define a tuple with a single element, always remember to include a trailing comma (e.g., <code>(2,)<\/code>). This distinction is important for avoiding confusion with simple expressions like <code>(2)<\/code> that do not create a tuple.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Which following is a tuple? A. [6, 5, 4] B. (2) C. 7 D. {3, 2, 1} The correct answer and explanation is: The correct answer is B. (2). A tuple in Python is an immutable ordered collection of elements. Tuples are typically enclosed in parentheses (), and they can store multiple items, just like [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-257056","post","type-post","status-publish","format-standard","hentry","category-exams-certification"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/257056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=257056"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/257056\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=257056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=257056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=257056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}