March 24, 2021

Decimal into Binary converter using python

In this blog you you can learn how to how to make decimal to binary converter program.


process of conversion :-












source code : 

#decimal to binary converter

def dec_bin(dec):                        #define function

    binnum=[0]*dec                        #list created

    i=0                                             #assign i for count

    while dec > 0:                            #while loop

        binnum[i] = dec%2                #logic part 1

        dec = dec//2                            #logic part 2

        i += 1                                      #increase by 1

    for j in range (i-1,-1,-1):                         #for loop for reverse the binary number to p

        print(binnum[j],end="")                    #printing binary number    

dec = int(input("enter the decimal number : "))                #take input through user 

dec_bin(dec)                                                                       #function calling.. 


No comments:

Post a Comment

find the cube of the range given digits. || codeAj

Find the cube of the range given Digits. Source Code r= int ( input ( "enter the range of digit : " )) def number_conter (n): ...