0 out of 464 challenges solved
Write a Python function `tuple_size` that takes a tuple as input and returns its size in bytes. Use the `sys.getsizeof` function from the `sys` module to determine the size of the tuple. #### Example Usage ```python [main.nopy] print(tuple_size(("A", 1, "B", 2, "C", 3))) # Example output: 88 (actual value may vary) print(tuple_size((1, "Raju", 2, "Nikhil", 3, "Deepanshu"))) # Example output: 104 (actual value may vary) print(tuple_size(((1, "Lion"), (2, "Tiger"), (3, "Fox"), (4, "Wolf")))) # Example output: 72 (actual value may vary) ``` #### Constraints - The input will always be a valid tuple. - The function should return an integer representing the size in bytes.
import sys def tuple_size(input_tuple): """ Calculate the size in bytes of the given tuple. Args: input_tuple (tuple): The tuple whose size is to be calculated. Returns: int: The size of the tuple in bytes. """ # Use sys.getsizeof to calculate the size of the tuple pass # Replace this with the actual implementation