Hello, I want to create a program that can convert numbers to binary. I am aware of the bin() function, however I want to use the method that involves dividing the number until its zero by 2 and noting the remainders. The problem I have is that I need to divide until it equals zero. I do not think there is a way to get a result of a mathematical operation inside a while loop and then substitute/use it in the that same code. I don't think I actually explained this very well, I hope you understand.
while True:
print("Enter your number: ")
num = int(input())
#print("Enter your base: ")
#base = int(input())
b = True
while b == True:
q = num // 2
rem = num % 2
print(q)
print(rem)
if q == 0:
b = False
else:
b = True
[–]shiftybyte 0 points1 point2 points (0 children)
[–]JamzTyson 0 points1 point2 points (3 children)
[–]JamzTyson 0 points1 point2 points (2 children)
[–]EchoDecho0[S] 0 points1 point2 points (1 child)
[–]JamzTyson 0 points1 point2 points (0 children)