Learn with Yasir

Share Your Feedback

Python Tuples Exercises – Practice Questions for Beginners

Strengthen your understanding of Python tuples with beginner-friendly exercises. Practice tuple creation, indexing, unpacking, and immutability through hands-on coding questions.

Topic: tuples


🧪 Coding Exercises

🟢 Beginner Exercises

  1. Create and Access Tuple
  2. Create a tuple containing three colors and print the second element.
    

    Requirements

    • Create a tuple with exactly 3 elements
    • Access the element at index 1

    Expected Output

    green


  3. Tuple Slicing
  4. Given a tuple (1, 2, 3, 4, 5), create a new tuple with elements from index 1 to 3.
    

    Requirements

    • Use slicing operation
    • Store result in a new variable

    Expected Output

    (2, 3, 4)


  5. Count Occurrences
  6. Count how many times the number 2 appears in the tuple (1, 2, 3, 2, 4, 2).
    

    Requirements

    • Use the count() method
    • Print the result

    Expected Output

    3


  7. Tuple Concatenation
  8. Combine two tuples (1, 2, 3) and (4, 5, 6) into a single tuple.
    

    Requirements

    • Use the + operator
    • Print the combined tuple

    Expected Output

    (1, 2, 3, 4, 5, 6)


  9. Find Index
  10. Find the index of the first occurrence of "apple" in the tuple ("banana", "apple", "orange", "apple").
    

    Requirements

    • Use the index() method
    • Print the result

    Expected Output

    1





  11. Convert List to Tuple
  12. Convert the list [1, 2, 3] to a tuple and print it.
    

    Requirements

    • Use the tuple() constructor
    • Print the resulting tuple

    Expected Output

    (1, 2, 3)


  13. Tuple Repetition
  14. Create a new tuple by repeating the tuple (1, 2) three times.
    

    Requirements

    • Use the * operator
    • Print the result

    Expected Output

    (1, 2, 1, 2, 1, 2)


🟡 Intermediate Exercises






  1. Unpack Tuple
  2. Unpack the tuple (10, 20, 30) into three variables a, b, c and print them.
    

    Requirements

    • Use tuple unpacking
    • Print all three variables

    Expected Output

    10 20 30


  3. Reverse Tuple
  4. Reverse the tuple (1, 2, 3, 4, 5) using slicing.
    

    Requirements

    • Use slicing with step parameter
    • Print the reversed tuple

    Expected Output

    (5, 4, 3, 2, 1)


  5. Nested Tuple Access
  6. Access the value "python" from the nested tuple (("java", "python"), ("c++", "ruby")).
    

    Requirements

    • Use chained indexing
    • Print the value

    Expected Output

    python




🔴 Advanced Exercises