1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
san4es73 [151]
3 years ago
3

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 binar

y. 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 // 2 Note: 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: 6 the output is: 110 Your 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) python
Computers and Technology
1 answer:
amm18123 years ago
3 0

Answer:

def integer_to_reverse_binary(integer_value):

   reverse_binary = ""

   while integer_value > 0:

       reverse_binary += str(integer_value % 2)

       integer_value = integer_value // 2

   

   return reverse_binary

   

def reverse_string(input_string):

   return input_string[::-1]

r = integer_to_reverse_binary(6)

print(reverse_string(r))

Explanation:

Create a function named integer_to_reverse_binary that takes one parameter, integer_value. Inside the function, initialize an empty string called reverse_binary to hold the result. Create a while loop that iterates while integer_value is greater than 0. Inside the loop, use the modulo operator to get the 0's and 1's and concatenate them to the reverse_binary. Use floor division to update the value of integer_value. After the loop, return the reverse_binary.

Create another function named reverse_string that takes one parameter, input_string. Inside the function, return the reverse of the input_string using slicing.

Call the functions to see the result

You might be interested in
Choose all statements that identify the benefits of programming design.
Lubov Fominskaja [6]

Answer:

yes

Explanation:

it provides a design approach to a specific type of problem

4 0
3 years ago
Read 2 more answers
(tco 7) the asp.net ajax client-side framework is loaded on the _____ for an asp.net web application.
jok3333 [9.3K]

a client-side framework is loaded on the client side, ie., the browser.

4 0
3 years ago
A company with a large number of hosts creates three subdomains under a main domain. For easier management of the host records,
REY [17]

Answer:

4

Explanation:

For easier management of the host records of the company 4 zones should be used because

subdomain is part of a larger domain and the main domain which is the primary domain is the name which the company have decide to use which will represent the company website address and in a situation where the company

have different domain names in which they had registered, they will need to choose one among the domain which will inturn be their main domain.

Therefore for easier , efficient and effective management of the host records 4 zones will be the best zones to be used.

Example of sub domain is north.example.com

4 0
4 years ago
Help please im not sure what this means T^T
Vesna [10]

Answer:

14

Explanation:

7 0
3 years ago
Read 2 more answers
Nanotechnology is a scientific area that deals with making or changing things that are incredibly _______________.
Dima020 [189]

Answer:

small

Explanation:

Nanotechnology deals with incredibly small things on the nanoscale.

3 0
3 years ago
Other questions:
  • What is the difference between Data and information?​
    7·1 answer
  • Mirrors on cars exist to____.
    7·2 answers
  • What will be the value of ans after the following code has been executed?
    10·2 answers
  • Anna’s computer will not power on. What aspect of the computer should Anna check (hardware or software)? How can Anna work to re
    5·1 answer
  • You have been asked to create a query that will join the Production.Products table with the Production.Categories table. From th
    6·1 answer
  • 1) You are working with an organization as a network manager. The organization has
    6·1 answer
  • Imagine a machine that produces an output force that is five times larger
    11·1 answer
  • The amount of data that can be stored on a disk depends in part on_____.
    13·1 answer
  • How can I use HTML to express a personal value
    13·1 answer
  • Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!