0 out of 464 challenges solved
Write a Python function `tuple_modulo` that takes two tuples of the same length and returns a new tuple where each element is the result of the modulo operation between the corresponding elements of the input tuples. #### Function Signature ```python [main.nopy] def tuple_modulo(tuple1: tuple, tuple2: tuple) -> tuple: ``` #### Input - `tuple1`: A tuple of integers. - `tuple2`: A tuple of integers of the same length as `tuple1`. #### Output - A tuple where each element is the result of `tuple1[i] % tuple2[i]`. #### Example Usage ```python [main.nopy] result = tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) print(result) # Output: (0, 4, 5, 1) result = tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) print(result) # Output: (5, 5, 6, 1) ```
def tuple_modulo(tuple1: tuple, tuple2: tuple) -> tuple: """ Perform element-wise modulo operation between two tuples of the same length. Args: tuple1 (tuple): The first tuple of integers. tuple2 (tuple): The second tuple of integers. Returns: tuple: A tuple containing the modulo results. """ # Ensure the tuples are of the same length if len(tuple1) != len(tuple2): raise ValueError("Tuples must be of the same length.") # Placeholder for the solution pass