In Python, a tuple is a collection data type that is ordered and immutable. Tuples are defined by placing the items inside parentheses, separated by commas. They can hold multiple types of data, including integers, strings, and other objects.
Here are some ways to create tuples in Python:
# Example of a simple tuple
my_tuple = (1, 2, 3)
print(my_tuple)
# Tuple with different data types
mixed_tuple = ("Hello", 42, 3.14, True)
print(mixed_tuple)
# Nested tuple
nested_tuple = (1, 2, (3, 4), 5)
print(nested_tuple)
# Tuple with single element (note the comma)
single_element_tuple = (42,)
print(single_element_tuple)
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?