implement a 2to1 multiplexer param input0 the first input value 0 or 1 param input1 the second input value 0 or 1 param select the select signal 0 or 1 to choose between input0 and input1 return the output based on the select signal input1 if select else input0 https www electrically4u comsolvedproblemsonmultiplexer https en wikipedia orgwikimultiplexer mux0 1 0 0 mux0 1 1 1 mux1 0 0 1 mux1 0 1 0 mux2 1 0 traceback most recent call last valueerror inputs and select signal must be 0 or 1 mux0 1 0 traceback most recent call last valueerror inputs and select signal must be 0 or 1 mux0 1 1 1 traceback most recent call last valueerror inputs and select signal must be 0 or 1 implement a 2 to 1 multiplexer param input0 the first input value 0 or 1 param input1 the second input value 0 or 1 param select the select signal 0 or 1 to choose between input0 and input1 return the output based on the select signal input1 if select else input0 https www electrically4u com solved problems on multiplexer https en wikipedia org wiki multiplexer mux 0 1 0 0 mux 0 1 1 1 mux 1 0 0 1 mux 1 0 1 0 mux 2 1 0 traceback most recent call last valueerror inputs and select signal must be 0 or 1 mux 0 1 0 traceback most recent call last valueerror inputs and select signal must be 0 or 1 mux 0 1 1 1 traceback most recent call last valueerror inputs and select signal must be 0 or 1
def mux(input0: int, input1: int, select: int) -> int:
    
    if all(i in (0, 1) for i in (input0, input1, select)):
        return input1 if select else input0
    raise ValueError("Inputs and select signal must be 0 or 1")


if __name__ == "__main__":
    import doctest

    doctest.testmod()