GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Tuples

Suja Nair Englisch

Inhalt der Mindmap

Tuples

  1. Definition

    • Immutable sequences
    • Used to store multiple items
  2. Creation

    • Using parentheses
      • Example: `my_tuple = (1, 2, 3)`
    • Using the `tuple()` constructor
      • Example: `my_tuple = tuple([1, 2, 3])`
  3. Tuple operation

    • Concatenation
      • Using `+` operator
        • Example: (1, 2) + (3, 4) results in (1, 2, 3, 4)
    • Replication
      • Using `*` operator
        • Syntax: `tuple_name * n`
  4. Modifying Tuples

    • Converting tuples to lists
      • Use list() function
  5. Built-in function

    • len()
      • Function that returns the number of items
        • Syntax: len(tuple)
    • tuple()
      • The tuple() constructor is used to create tuples. It can create an empty tuple or convert an iterable (like a list, string, or set) into a tuple.
    • count()
      • A method to count occurrences
      • Returns the number of times a value appears
        • Example tuple: (1, 2, 2, 3, 4)
          • count(2) returns 2
    • index()
      • A method used to find the first occurrence of a value
        • Syntax
          • Written as `tuple.index(value, start, end)`
        • Returns the index of the first occurrence of the value
    • sorted()
      • Used to sort iterables
      • Returns a new sorted list
      • Convert tuple to a list
      • Syntax
        • sorted(<iterable sequence>, [reverse=False])
    • min()
      • Returns the smallest element
        • Example: result = min(my_tuple)
    • max()
      • Returns the largest element
        • Example: result = max(my_tuple)
    • sum()
      • Calculates the total of numeric values
        • Example: sum((1, 2, 3)) returns 6
  6. Type of tuple

    • Single element tuple. eg. T= (12,)
    • Nested Tuple eg. T= (23, (45, 67, 88), 56, 78)
    • Empty tuple eg. T= ()

Informationen

Beschreibung
Mindmap am Tuples, erstellt von Suja Nair am 17/05/2025.
Erstellt von
Suja Nair
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck