My QA Projects

QA Projects I was involded.

View on GitHub

Tuples

Type Sequence Mutable
tuple YES NO
String YES NO
Range YES NO
List YES YES
Set NO YES
Dict NO YES

you need tuples when you have to deal with

Tuple Advantages

Tuple Literals

()
(,)

Single item Tuple

(item,)
# single item requires a comma
(item) == item
# distinguishes a tuple from a single item

Tuple Function

tuple(container)
# return a tuple from a given container
# returns a tuple version of it

Tuple Assignment

Tuple Assignment Example

t = (1,20,300)
a,b,c = t

# Output
1
20
300

Tuple Conversion

Example membership operators

# Sample tuple
numbers = (1, 2, 3, 4, 5)

# Check if 3 is in the tuple
print(3 in numbers)  # Output: True

# Check if 10 is not in the tuple
print(10 not in numbers)  # Output: True

  back