In: Computer Science
# Function to convert decimal number
# to binary using recursion
def DecimalToBinary(num,l):
if num > 1:
DecimalToBinary(num // 2,l)
l.append(str(num % 2))
return l
def flip_B_bits(l):
for i in range(len(l)):
if l[i] =="0":
l[i] ="1"
else:
l[i] = "0"
print("after fliping bits B is")
print(''.join(l))
# Driver Code
if __name__ == '__main__':
# decimal value
print("enter value of A")
A = int(input())
num=[]
# Calling function
DecimalToBinary(A,num)
print(''.join(num))
print("enter value of B")
B= int(input())
num=[]
DecimalToBinary(B,num)
print(''.join(num))
flip_B_bits(num)