'How does this code convert the decimal to binary? [duplicate]
Having difficulty to understand this code. Can somebody explain to me in a simple way.
# decimal to binary
def convert(num):
if num == 0:
return 0
else:
#explain this part
--> return (num % 2 + 10 * convert(num // 2)) <--
decimal = int(input())
print(convert(decimal))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
