Python Tuple Practice Questions

Practice the core tuple concepts from creation and conversion through indexing, built-in functions, immutability and the count() method. Try each question before opening the solution.

  1. Create an empty tuple with the constructor and check its type
    Show solution
    my_tuple = tuple()
    print(my_tuple)
    print(type(my_tuple))
  2. Create an empty tuple using tuple literal syntax
    Show solution
    my_tuple = ()
    print(my_tuple)
  3. Create a tuple containing five integers
    Show solution
    numbers = (10, 20, 30, 40, 50)
    print(numbers)
  4. Create a tuple from range()
    Show solution
    numbers = tuple(range(5, 50, 10))
    print(numbers)
  5. Unpack a tuple and display its elements
    Show solution
    my_tuple = ('Alex', 'Ronald', 'John')
    print(*my_tuple)
  6. Create a tuple from a list
    Show solution
    names = ['Alex', 'Ronald', 'John']
    my_tuple = tuple(names)
    print(my_tuple)
  7. Create a tuple containing duplicate values. Does a tuple allow duplicates?
    Show solution
    my_tuple = ('a', 'b', 'a', 'c', 'a')
    print(my_tuple)
    # Yes. Tuples can contain duplicate values.
  8. Create a one-item tuple and verify its type
    Show solution
    one_item = ('Alex',)
    print(one_item)
    print(type(one_item))
  9. Use max(), min(), sum() and len() with a numeric tuple
    Show solution
    numbers = (8, 2, 4, 3, 7, 3)
    print(max(numbers))
    print(min(numbers))
    print(sum(numbers))
    print(len(numbers))
  10. Try to clear a tuple. What happens?
    Show solution
    my_tuple = (1, 2, 3)
    my_tuple.clear()  # AttributeError: tuple has no clear() method
  11. Count how many times a value occurs in a tuple
    Show solution
    my_tuple = ('a', 'c', 'd', 'c', 'x', 'k', 'd', 'c')
    print(my_tuple.count('c'))
  12. Read values at different tuple positions
    Show solution
    my_tuple = ('a', 'c', 'd', 'c', 'x', 'k', 'd', 'c')
    print(my_tuple[0])   # first
    print(my_tuple[-1])  # last
    print(my_tuple[2])   # third
    print(my_tuple[1:4]) # slice
Remember: tuples are ordered and support indexing, but they are immutable. A tuple has no clear() method.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer