Homework
Below is an example of decimal number to binary converter which you can use as a starting template.
num = int(input("What is your decimal number"))
def DecimalToBinary(num):
strs = ""
while num:
# if (num & 1) = 1
if (num & 1):
strs += "1"
# if (num & 1) = 0
else:
strs += "0"
# right shift by 1
num >>= 1
return strs
# function to reverse the string
def reverse(strs):
strv = (strs[::-1])
return strv
# Driver Code
print("Binary number for", num, "is: ",reverse(DecimalToBinary(num)))