a nor gate is a logic gate in boolean algebra which results in false0 if any of the inputs is 1 and true1 if all inputs are 0 following is the truth table of a nor gate truth table of nor gate input 1 input 2 output 0 0 1 0 1 0 1 0 0 1 1 0 code provided by akshaj vishwanathan https www geeksforgeeks orglogicgatesinpython norgate0 0 1 norgate0 1 0 norgate1 0 0 norgate1 1 0 norgate0 0 0 0 1 norgate0 7 0 printtruthtablenorgate truth table of nor gate input 1 input 2 output 0 0 1 0 1 0 1 0 0 1 1 0 maketablerowone two three one two three nor_gate 0 0 1 nor_gate 0 1 0 nor_gate 1 0 0 nor_gate 1 1 0 nor_gate 0 0 0 0 1 nor_gate 0 7 0 print truth_table nor_gate truth table of nor gate input 1 input 2 output 0 0 1 0 1 0 1 0 0 1 1 0 make_table_row one two three one two three
from collections.abc import Callable


def nor_gate(input_1: int, input_2: int) -> int:
    
    return int(input_1 == input_2 == 0)


def truth_table(func: Callable) -> str:
    

    def make_table_row(items: list | tuple) -> str:
        
        return f"| {' | '.join(f'{item:^8}' for item in items)} |"

    return "\n".join(
        (
            "Truth Table of NOR Gate:",
            make_table_row(("Input 1", "Input 2", "Output")),
            *[make_table_row((i, j, func(i, j))) for i in (0, 1) for j in (0, 1)],
        )
    )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    print(truth_table(nor_gate))