2121"""
2222
2323
24- def full_adder (a : int , b : int , cin : int ) -> tuple [int , int ]:
24+ def full_adder (input_a : int , input_b : int , carry_in : int ) -> tuple [int , int ]:
2525 """
2626 Compute the sum and carry-out for a Full Adder.
2727
2828 Args:
29- a : First input bit (0 or 1).
30- b : Second input bit (0 or 1).
31- cin : Carry-in bit (0 or 1).
29+ input_a : First input bit (0 or 1).
30+ input_b : Second input bit (0 or 1).
31+ carry_in : Carry-in bit (0 or 1).
3232
3333 Returns:
3434 A tuple `(sum_bit, carry_out)`.
@@ -49,14 +49,14 @@ def full_adder(a: int, b: int, cin: int) -> tuple[int, int]:
4949 Raises:
5050 ValueError: If any input is not 0 or 1.
5151 """
52- if a not in (0 , 1 ) or b not in (0 , 1 ) or cin not in (0 , 1 ):
52+ if input_a not in (0 , 1 ) or input_b not in (0 , 1 ) or carry_in not in (0 , 1 ):
5353 raise ValueError ("Inputs must be 0 or 1." )
5454
5555 # Sum is XOR of the inputs
56- sum_bit = a ^ b ^ cin
56+ sum_bit = input_a ^ input_b ^ carry_in
5757
5858 # Carry-out is true if any two or more inputs are 1
59- carry_out = (a & b ) | (b & cin ) | (a & cin )
59+ carry_out = (input_a & input_b ) | (input_b & carry_in ) | (input_a & carry_in )
6060
6161 return sum_bit , carry_out
6262
0 commit comments