Write a program that takes in a positive integer as input, and…

  

Write a program that takes in a positive integer as input, and… 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 binary. For an integer x, the algorithm is:As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2Note: The above algorithm outputs the 0’s and 1’s in reverse order. You will need to write a second function to reverse the string.Ex: If the input is:6the output is:110Your program must define and call the following two functions. The function integer_to_reverse_binary() should return a string of 1’s and 0’s representing the integer in binary (in reverse). The function reverse_string() should return a string representing the input string in reverse.def integer_to_reverse_binary(integer_value)def reverse_string(input_string) This is what I have so far but I’m still getting the questions below wrong and I’m not sure what to change/add.    def reverse_string(input_string):s = ”for i in input_string:s = i + sreturn sdef integer_to_reverse_binary(integer_value):s = ”while(integer_value>0):s = s + str(integer_value % 2)integer_value = integer_value //2return reverse_string(s)print(integer_to_reverse_binary(6))  2: Unit test0 / 2 Convert 19 to binary using integer_to_reverse_binary() and reverse_string()Your output110 integer_to_reverse_binary(19) incorrectly returned 10011 4: Unit test0 / 3 Convert 122 to binary using integer_to_reverse_binary() and reverse_string()Your output110 integer_to_reverse_binary(122) incorrectly returned 1111010 Computer Science Engineering & Technology Python Programming CIS 121

Don't use plagiarized sources. Get Your Custom Essay on
Write a program that takes in a positive integer as input, and…
Just from $13/Page
Order Essay
  

Leave a Reply

Your email address will not be published.

Related Post

Open chat
💬 Need help?
Hello 👋
Can we help you?