From 15de9d9708bdbed32098b80a84317ca01e74ccd6 Mon Sep 17 00:00:00 2001 From: Tanishka Gupta Date: Wed, 7 Oct 2020 16:01:05 +0530 Subject: [PATCH 1/3] decimal to binary convention --- python/DecimalToBinary.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python/DecimalToBinary.py b/python/DecimalToBinary.py index e0d6d629..cdf7620a 100644 --- a/python/DecimalToBinary.py +++ b/python/DecimalToBinary.py @@ -1,11 +1,5 @@ def DecimalToBinary(x): - BinaryNumb = "" - while x>0: - if x%2 == 0: - BinaryNumb = "0 "+BinaryNumb - else: - BinaryNumb = "1 "+BinaryNumb - x//=2 + BinaryNumb = '0' + bin(x)[2:] return BinaryNumb def main(): From 867f6d5899c4f011c72585cc73f341b5c140c974 Mon Sep 17 00:00:00 2001 From: Tanishka Gupta Date: Wed, 7 Oct 2020 16:07:45 +0530 Subject: [PATCH 2/3] please commit changes --- python/DecimalToBinary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/DecimalToBinary.py b/python/DecimalToBinary.py index cdf7620a..4c817c8e 100644 --- a/python/DecimalToBinary.py +++ b/python/DecimalToBinary.py @@ -1,5 +1,5 @@ def DecimalToBinary(x): - BinaryNumb = '0' + bin(x)[2:] + BinaryNumb = '0' + bin(x)[2:] return BinaryNumb def main(): From cfa47cf1ea923ee9905547b576b76b7b43c519df Mon Sep 17 00:00:00 2001 From: Tanishka Gupta Date: Wed, 7 Oct 2020 16:20:57 +0530 Subject: [PATCH 3/3] update --- python/DecimalToBinary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/DecimalToBinary.py b/python/DecimalToBinary.py index 4c817c8e..cdf7620a 100644 --- a/python/DecimalToBinary.py +++ b/python/DecimalToBinary.py @@ -1,5 +1,5 @@ def DecimalToBinary(x): - BinaryNumb = '0' + bin(x)[2:] + BinaryNumb = '0' + bin(x)[2:] return BinaryNumb def main():