About 179,000 results
Open links in new tab
  1. Python Tuples - W3Schools

    Tuples are used to store multiple items in a single variable. Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage. A tuple is a collection which is ordered and unchangeable. Tuples are written with round brackets. Create a Tuple:

  2. python - Getting one value from a tuple - Stack Overflow

    Is there a way to get one value from a tuple in Python using expressions? def tup (): return (3, "hello") i = 5 + tup () # I want to add just the three I know I can do this: (j, _) = tup () i = ...

  3. How do I get integers from a tuple in Python? - Stack Overflow

    Jul 20, 2010 · I have a tuple with two numbers in it, I need to get both numbers. The first number is the x-coordinate, while the second is the y-coordinate. My pseudo code is my idea about how to go about it, however I'm not quite sure how to make it work. pseudo code: int1 would return 46, while int2 would return 153. Please don't use tuple as a variable name.

  4. Python Tuple: How to Create, Use, and Convert

    Jun 24, 2024 · Creating a Python tuple. We create tuples from individual values using optional parentheses (round brackets) like this: >>> my_numbers = (1, 2, 3) >>> the_same = 1, 2, 3 >>> my_strings = ('Hello', 'World') >>> my_mixed_tuple = ('Hello', 123, True) Like everything in Python, tuples are objects and have a class that defines them.

  5. Tuple Operations in Python - GeeksforGeeks

    Apr 11, 2025 · To find the length of a tuple, we can use Python’s len () function and pass the tuple as the parameter. Tuples in Python are heterogeneous in nature. This means tuples support elements with multiple datatypes. We can convert a list in Python to a tuple by using the tuple () constructor and passing the list as its parameters. Output:

  6. Python Program to Create a Tuple with Numbers - Tutorial …

    Write a Python Program to Create a Tuple with Numbers or a numeric tuple. The first one will create a tuple with 22 as a value. # Example nTuple = 22, print("Tuple Items = ", nTuple) numTuple = (10, 20, 40, 60, 80, 100) print("Tuple Items = ", numTuple)

  7. Python's tuple Data Type: A Deep Dive With Examples

    In Python, a tuple is a built-in data type that allows you to create immutable sequences of values. The values or items in a tuple can be of any type. This makes tuples pretty useful in those situations where you need to store heterogeneous data, like that in …

  8. Python Tuples: A Step-by-Step Tutorial (with 14 Code Examples)

    Mar 28, 2022 · Python has a built-in sequence data type to store data in an unchangeable object, called a tuple. After you finish this Python tutorial, you'll know the following: In this tutorial, we assume you know the fundamentals of Python, including …

  9. Extract specific number from tuple value in Python

    Mar 2, 2016 · You don't have any integers in your object. You have a decimal.Decimal() object, which models a Real number instead. Your tuple contains only one element, a dictionary, with one key-value pair. If you wanted to extract that pair, you'd need to address it:

  10. Python Tuples - Python Tutorial

    Tuples are ordered, immutable collections that can hold heterogeneous data. Tuples support indexing, slicing, and nested structures. You can perform tuple operations like concatenation and repetition. Tuple methods are limited compared to lists, but …

  11. Some results have been removed