Answer to Question #186338 in Python for Woyengimiesindo Malati

Question #186338

Write a program that reads a number and prints all of its binary digits: Print the remainder

number % 2, then replace the number with number / 2. Keep going until the number is 0. For 

example, if the user provides the input 13, the output should be

1


1

1


1
Expert's answer
2021-04-27T14:22:03-0400
number = int(input("Enter the number: "))

while number > 1:

   remainder = number % 2

   print(remainder)

   number = number//2

   if number == 1 or number == 0:

      print(number)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS