Tuple

A tuple (pronounced "tuh-pull") is a data structure that stores a specific number of elements. These elements may include integers, characters, strings, or other data types.

Mathematics

The term "tuple" originates from math, rather than computer science. A math tuple may be defined as an "n-tuple," where "n" is the number of values the tuple contains. In mathematical expressions, tuples are represented by comma-delimited lists within parentheses. The following example is a "4-tuple," which has four values.

(3, 7, 13, 17)

Tuples serve a variety of purposes in mathematics. They are commonly used to represent a set of related values, such as prime numbers or mathematical sequences. A tuple can also display a range of input or output values for a function.

Computer Science

In computer programming, tuples provide an efficient way to store multiple values. Since they are static and cannot be modified, tuples generally require less memory than arrays. They are also flexible since they can store multiple data types. The following example is a "5-tuple," or a tuple that contains five values.

(11, 2020.07, "techterms", "C", -1000)

The "pentuple" above contains a positive integer (11), floating point number (2020.07), string (techterms), character (C), and a negative integer (-1000).

Tuples are an effective way to store data in computer programs, but not all programming languages support them. For example, Python and Java support tuples, but PHP and Ruby do not. If a language does not support tuples, an immutable array — one that cannot be modified — is the closest alternative.

Updated July 11, 2020 by Per C.

quizTest Your Knowledge

In the context of computer-generated simulation, XR is short for ____ reality?

A
Extreme
0%
B
Excess
0%
C
Expanded
0%
D
Extended
0%
Correct! Incorrect!     View the Extended Reality definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Tuple on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.