Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

Decimal to Binary in Python

Python program to get decimal number and convert it into binary.

Sample Input 1:

11

Sample Output 1:

1011

Program or Solution

					    
							
binary_num,base=0,1
decimal_num=int(input("Enter a Decimal number:"))
while (decimal_num > 0):
    remainder = decimal_num % 2
    binary_num = binary_num + remainder * base
    decimal_num = decimal_num // 2
    base = base * 10
print(binary_num)

					    
					

Program Explanation

Yet to be updated