I need help with this small coding I need help creating a co
I need help with this small coding!!!!
I need help creating a converting of decimal to binary. It must be writtening in Python
I dont understnad how to create this in coding. The python cannot have conditions or loops!
Remainder 2)156 2)78 2) 78 2)39 0 2) q 2)4 2) 2) 2 2) I 0 0 wi ki How to Convert from Decimal to BinarySolution
Using built in function bin()
dec = 52
print(\"The decimal value of\",dec,\"is:\")
print(bin(dec), \"in binary\")
Output
110100 in binary
Without using bin():
n = input(\"enter a number :\")
no = int(n)
binaryStr = \"\"
while no > 0:
binaryStr = str(no % 2) + binaryStr
no = no // 2
print(\"The binary number is : \",binaryStr)
Output:
Enter a number: 42
The binary number is : 101010
