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

Definitions by TechTerms.com

The definition of Tuple on this page is an original TechTerms.com definition. If you would like to reference this page or cite this definition, you can 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 the Tuple definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

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.