5.14 lab: convert to reverse binary write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in reverse binary. for an integer x, the algorithm is: as long as x is greater than 0 output x modulo 2 (remainder is either 0 or 1) assign x with x divided by 2

Respuesta :

A program that prints output of an algorithm in reverse is given below, complete with the algorithm:

The Algorithm

step1 = input("what number? ")#gets your input

step2 = int(step1) #makes sure it's an int not float

step3 = bin(step2) #converts it to binary (you method doesn't work for e.g. 7)

step4 = step3.replace("0b", "") #removes 0b from the binairy number

step5 = step4[::-1] #reverses the string

print (step5)

The Program

num = int(input())

while num > 0:

   y = ( num % 2 )

   print( y , end = ' ' )

   num = ( num / / 2 )

print ( )

num = int ( input ( " Enter a number " ) )

string = " "

while num > 0 :

   y = str ( num % 2 )

   string + = y

   num = ( num / / 2 )

reverse = string [ : : - 1 ]

print ( reverse )

Read more about programming here:

https://brainly.com/question/23275071

#SPJ1