diff --git a/projects/021-decimal-to-binary/python/main.py b/projects/021-decimal-to-binary/python/main.py index e69de29..d0bf232 100644 --- a/projects/021-decimal-to-binary/python/main.py +++ b/projects/021-decimal-to-binary/python/main.py @@ -0,0 +1,11 @@ +integer=int(input("Enter an integer: ")) +result="" +quotient=integer + +while quotient!=0: + + remainder=quotient%2 + quotient//=2 + result+=str(remainder) + +print(f"The binary representation of {integer} is {result[::-1]}") \ No newline at end of file