diff --git a/binary equivalent.py b/binary equivalent.py new file mode 100644 index 0000000..0a2e220 --- /dev/null +++ b/binary equivalent.py @@ -0,0 +1,16 @@ +a=int(input("Enter a natural number"))#Taking input +if a==0: + print(0) +else: + l=[] + while(a>0): + b=a%2 #Calculating the remainder + a=a//2 #Updating the value of a + l.append(b) #Storing the values of b in a list + l.reverse() +print("The binary equivalent is:",end="") +for i in l: + print(i,end="") + + +