diff --git a/projects/021-decimal-to-binary/python/main.py b/projects/021-decimal-to-binary/python/main.py index e69de29..256c699 100644 --- a/projects/021-decimal-to-binary/python/main.py +++ b/projects/021-decimal-to-binary/python/main.py @@ -0,0 +1,10 @@ +result = '' +q = int(input('Enter a decimal number: ')) +decimal = q + +while q > 0: + r = str(q % 2) + result = r + result + q = q // 2 + +print(f'The binary number of {decimal} is: {result}') \ No newline at end of file