Consider a circuit that takes the numbers 0 through 7 as inputs (0=000,1=001, 2=010, ..., 7=111) and produces an output of 1 if and only if the input is an odd number). Write the function and simplify.
Consider a circuit that takes the numbers 0 through 7 as inputs (0=000,1=001, 2=010, ..., 7=111) and produces an output of 1 if and only if the input is an odd number). Write the function and simplify.
we have to taken input 0 to 7 in binary number if number is odd then print 1 and number is even print 0.
# Returns true if n is even, else odd
def even(n): # declare function even
even = True; # declare variable even is true
for i in range(1, n+1): # for loop for 1 to n+1 term
if even == True: # condition to check value is even or odd
even = False;
else:
even = True;
return even; # return the value even or odd
# in this code even is zero (0) and odd is one (1)
Step by step
Solved in 2 steps with 1 images