Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.8 KB

File metadata and controls

43 lines (36 loc) · 1.8 KB

🧠 Common Questions (20)

  1. What is a tuple in Python?
  2. How do you create an empty tuple?
  3. How does a tuple differ from a list?
  4. Are tuples mutable or immutable?
  5. Can you change elements in a tuple after creation?
  6. How do you create a single-element tuple?
  7. How do you access elements in a tuple?
  8. What is tuple packing?
  9. What is tuple unpacking?
  10. Can tuples contain mutable objects like lists?
  11. How do you concatenate two tuples?
  12. How do you repeat a tuple multiple times?
  13. Can you use tuples as dictionary keys? Why?
  14. What methods are available for tuples?
  15. How do you find the length of a tuple?
  16. How do you find the index of an element in a tuple?
  17. How do you count occurrences of an element in a tuple?
  18. Can you sort a tuple?
  19. What are named tuples in Python?
  20. What are the performance benefits of using tuples over lists?


💻 Programming Questions with Tuples (10)

  1. Write a program to unpack a tuple into four different variables.
  2. Write a function that accepts a list of numbers and returns a tuple containing the sum and average.
  3. Create a program that converts a tuple of strings to a single string.
  4. Given a list of tuples [('Alice', 88), ('Bob', 95), ('Charlie', 88)], sort it by score (descending) and then by name (ascending).
  5. Write a program to find all duplicate elements in a tuple.
  6. Create a tuple containing a list and demonstrate how to add a new element to the list within the tuple.
  7. Write a function to reverse a tuple without converting it to a list.
  8. Given two tuples, write a program to find common elements between them.
  9. Write a program to convert a number into a tuple of its individual digits.
  10. Create a named tuple to represent a Point with x, y, and z coordinates.