Tuples
Tuples
Given two tuples, t1 and t2, compare them and determine if they are equal or which one is greater.
python
Copy code
# Example
t1 = (1, 2, 3)
t2 = (1, 2, 4)
# Output: t1 < t2
You have a tuple t containing several elements. Convert it to a list and modify one of the elements.
Then, convert it back to a tuple.
python
Copy code
# Example
t = (1, 2, 3, 4)
# Your code here to convert t to a list, modify an element, and convert back to a tuple
Given a tuple t of integers, find the maximum and minimum values without using built-in functions.
python
Copy code
# Example
t = (5, 2, 9, 1, 5, 6)
You are given a tuple t and a specific value. Count how many times that value appears in the tuple.
python
Copy code
# Example
# Output: 3
Given a list of integers, create a tuple containing only the even numbers from that list.
You are given a tuple t containing two elements. Swap the elements of the tuple.
python
Copy code
# Example
t = (1, 2)
# Output: (2, 1)
Given a tuple data containing the name, age, and city of a person, unpack the values into separate
variables.
python
Copy code
# Example
You have a tuple t with several elements. Count how many times a specific element appears in the
tuple.
python
Copy code
# Example
t = (1, 2, 3, 1, 4, 1, 5)
element = 1
# Output: 3
Given a tuple t and a specific element, find the index of that element in the tuple.
python
Copy code
# Example
element = 'c'
# Output: 2
You have two tuples, t1 and t2. Concatenate these two tuples into a new tuple.
python
Copy code
# Example
t1 = (1, 2, 3)
t2 = (4, 5)
# Output: (1, 2, 3, 4, 5)