Tuple: Difference between revisions
Mr. MacKenty (talk | contribs) (Created page with "right|frame|Programming basics<ref>http://www.flaticon.com/</ref> A tuple is a data structure that is an immutable, or unchangeable, ordered sequence of e...") |
Mr. MacKenty (talk | contribs) |
||
Line 13: | Line 13: | ||
# creating a tuple | # creating a tuple | ||
mySiblings = ('Susan', 'James', 'Bryan') | mySiblings = ('Susan', 'James', 'Bryan') | ||
# accessing an element within a tuple: | |||
mySiblings[2] | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Do you understand this?== | == Do you understand this?== |
Revision as of 06:24, 8 August 2017
A tuple is a data structure that is an immutable, or unchangeable, ordered sequence of elements. Because tuples are immutable, their values cannot be modified.[2]
As a general rule, tuples use less memory than a list or array.
Tuples allows for slicing and indexing like lists, but do not have access for deleting or changing any elements.
Example[edit]
# creating a tuple
mySiblings = ('Susan', 'James', 'Bryan')
# accessing an element within a tuple:
mySiblings[2]