python
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 // 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
The program must define and call the following two functions. Define a function named int_to_reverse_binary() that takes an integer as a parameter and returns a string of 1's and 0's representing the integer in binary (in reverse). Define a function named string_reverse() that takes an input string as a parameter and returns a string representing the input string in reverse.
def int_to_reverse_binary(integer_value)
def string_reverse(input_string)
main.py
# Define your function here.
if __name__ == '__main__':
# Type your code here. Your code must call the function.

Answers

Answer 1

The program illustrates the use of loops .

Loops are used for operations that must be repeated until a certain condition is met.

How to write the program?

The program written in Python, where comments are used to explain each action is as follows:

#This defines the int_to_reverse_binary function

def int_to_reverse_binary(integer_value):

   #This initializes the string output

   strNum = ""

   #The following loop calculates the string output

   while (integer_value > 0):

       strNum += str(integer_value % 2)

       integer_value //= 2

   #This passes the string output to the string_reverse function

   string_reverse(strNum)

#This defines the string_reverse function

def string_reverse(input_string):

   #This reverses the string

   strRev = input_string[::-1]

   #This prints the reversed string

   print("Binary number:",strRev)

# The main begins here

if __name__ == '__main__':

   #This gets the decimal value

   dec_val = int(input("Decimal value: "))

   #This calls the int_to_reverse_binary function

   int_to_reverse_binary(dec_val)

   

Read more about Python programs at:

https://brainly.com/question/24833629


Related Questions

Which one of the following document types would you not use the Microsoft Excel program to create?

Answers

I would say letters.

Explanation:

I hope this helps you


Driving is a ____
business.
a) safe
b) daring
c) boring

Answers

Driving is a daring business.

Driving is a daring business. Thus the correct answer is B.

What is a business?

Business is referred to as an activity of an economy in which trading of goods and services will be done. Trading of goods means buying and selling goods from one country to another with the process of export and import.

Driving is considered a daring busines because it is considered as an adventurous activity in which a driver has to ride the vehicle from various locations having certain difficulties faced challenges.

This difficulty includes conditions of the roads, areas like mountains, and slopes, and weather conditions, as fog where visibility is quite low which, may result in a lack of concentration on driving.

The poor condition of roads and adverse weather conditions create great risk while driving. It may cause a threat of life while driving if it causes any type of injury or accident.

Therefore, option B daring is appropriate.

Learn more about Driving, here:

https://brainly.com/question/10648228

#SPJ5

4.which pre-defined feature is known as functions in Excel?
a.formula
b.property
c. data

Answers

Answer:

I think formula?

Explanation:

The math function ceil(x) returns the smallest integer that is greater than or equal to x. True False

Answers

Answer:

Hello the answer is True.

Hope this helps!✌

The math function ceil(x) returns the smallest integer that is greater than or equal to x. The statement is false.

what is integer ?

An integer which is a number consist of 0, positive numbers, and negative numbers, be noted that an integer can not be a fraction, a decimal or a per cent, for example 1, 3, 4, 8, 99, 108, -43, -556, etc

These are the group of counting numbers such as positive and negative, and zero, that can be written without a fractional component. All natural numbers are  integers which can start from 1 and end at infinity.

All whole numbers are  integers, starting from 0 and ending at infinity, it can be of two types such as Positive Numbers and Negative Integer

In the number system, there are various types of numbers under the integer category such as Whole numbers, Natural numbers, Odd and Even integers, Prime and composite numbers

For more details regarding integer, visit

https://brainly.com/question/28513507

#SPJ2

A pointing device used mainly for computer games is known as
A.stylus
B.Digitizer
C.joystick

Answers

Answer: Joystick is the only one that makes sense, a stylus and digitizer are both used on drawing tablets, not computer games.

Shelly uses Fac3book to interact with friends and family online. When is she most likely to express a positive mood on social media?

a.
Sundays
b.
Wednesdays
c.
Fridays
d.
Thursdays

Answers

Answer:

Fridays

Explanation:

On record, Fridays are preffered

The correct option is c. Fridays.

What is Social media?Social media refers to the means of relations among people in which they create, share, and/or interact with information and ideas in virtual societies and networks. In today's civilization, the use of social media has evolved into a necessary daily exercise. Social media is commonly used for social relations and credentials to news and information, and determination making. It is a valuable contact tool with others locally and worldwide, as well as to communicate, create, and spread announcements.

To learn more about Social media, refer to:

https://brainly.com/question/1163631

#SPJ2

One new and creative method companies are using to advertise is:
A. stealing people's identities and pretending to be their friend.
B. promoting their products in television advertisements.
c. advertising products on the websites people visit the most.
O D. awarding prizes to users who follow them on social media.
SUBMIT

Answers

Answer:

c. advertising products on the websites people visit the most.

Explanation:

What's better, adventure time or regular show?

Answers

i would have to say regular show

The page that appears when you first open your Internet browser is the _____.


opening page
opening page

launch page
launch page

home page
home page

first page
first page

Answers

Answer:

launch page

Explanation:

You can change your launch page in settings.

Your launch page will be launched as soon as you reopen a browser.

Answer:

Launch page

Explanation:

Mateo wants the words "it’s snowing!" to appear in the output box and typed print (it’s snowing). this didn’t work. what needs to be added to the code?

a.
quotation marks
b.
a backslash
c.
a period
d.
a functional code

Answers

the answer is b . i just got this question right .

Answer:

a Quotation marks

Explanation:

In python, to print something it needs to have parenthesees and quotation marks.
a. Quotation marks

Explain two protocols to enhance cellular networks capacity?


Notes:
- You need to cite used references in your submission.

Answers

The mobile network capacity can be improved by increasing the radio spectra or also increasing the re-utilization of a given spectrum.

What is mobile network capacity?

The mobile network capacity refers to the final volume of information (data) that can be transferred to a particular customer.

A mobile wireless system refers to a given network where the connection to and from customers consists of wireless technology.

The mobile network capacity is usually improved in a given area by increasing the radio spectra or increasing the re-utilization of the spectrum.

Learn more about mobile wireless systems here:

https://brainly.com/question/1763761

is climate change really caused by human activities introduction​

Answers

Yes, climate change is mainly caused by human activities. While there are other factors, people are by far the leading cause. Factories and vehicles pump harmful gasses into the atmosphere on a daily basis, depleting the ozone layer. The land and ocean are littered with trash and waste. To build homes and stores, more and more forests are cut down that bring homes to other animal and oxygen into the atmosphere.

08. Consider the following four binary numbers.
11100111
10101010
11110000
11001100
Which of the following displays the numbers in ascending order?
(A) 10101010, 11001100, 11100111, 11110000
(B) 11110000, 11100111, 11001100, 10101010
(C) 11100111, 10101010, 11110000, 11001100
(D) 10101010, 11001100, 11110000, 11100111

Answers

Answer: A
Explanation: If you convert the binary into decimal
you can easily determine the order from least to
greatest. In this instance of "a," we have 170, 204,
231, 240.

How dose computers it use the information to solve problems

Answers

Answer:

A programmer's job is to find solutions. They break down problems into easy steps for a computer. 

Explanation:

hope I'm helping you!

A flowchart is a useful visual that can __________.a. be used to show spatial relationships.b. be used to show frequency or distribution of parts in a whole.c. be used to show trends in one or more variables.d. be used to illustrate processes or procedures.

Answers

Explanation:

in my book flowchart is a graphical symbolic representation of computer

______________ refers to the practice of ordering extra inventory beyond expected demand to prevent stockouts while the ______________ refers to an inventory management technique where an incoming train unloads materials directly into outbound trucks.

Answers

Safety stock inventory management  refers to the practice of ordering extra inventory beyond expected demand to prevent stockouts.

What is Safety stock inventory?

Safety stock inventory management is known to be a kind of more or extra inventory that is said to have been ordered way above the expected demand.

Note that this technique is often used to stop or hinder any form of stockouts that is said to have been caused by incorrect forecasting or unforeseen events in customer demand.

Learn more about Safety stock inventory form

https://brainly.com/question/26954616

Social media tools allow you to connect with people anywhere in the world who share your interests evaluate your interactions with people living outside the United States using various Social media tools how his influences how do you break cultural stereotypes and discover the local activities career aspirations in sports preferences of people from other cultures what is a social media tools that you used to form these connections explain how these connections have been influenced you, providing specific examples

Answers

The social media tools that you used to form these connections are:

Buzz Sumo. Go ogle Trends. Buffer Publish.Can va. Un splash

What are social media tools?

Social media tools are known to be key tools that are used for the running of business so as to handle important ways in their Digital Marketing routine.

The social media tools are important because it helps one to plan ahead and also  ensure that a person post the type of content needed to reach your goals and grow one's business.

Learn more about  social media from

https://brainly.com/question/3653791

How do you find binary?

Answers

Answer:

To convert integer to binary, start with the integer in question and divide it by 2 keeping notice of the quotient and the remainder. Continue dividing the quotient by 2 until you get a quotient of zero. Then just write out the remainders in the reverse order.

Explanation:

What problem does computer science solve in dance?

Answers

Answer:

Computer science, your able to make websites that might have videos on teaching you dance techniques.

B. State True or False: 1. 'Date within' option allows you to search an email within a specified date range.​

Answers

Answer + Explanation:

his topic describes the email and document properties that you can search for in email items in Exchange Online and documents stored on SharePoint and OneDrive for Business sites by using the Content Search feature in the Security & Compliance Center. You can also use the *-Compliance Search cmdlets in Security & Compliance Center PowerShell to search for these properties

Please have a great day <3

Which practice enables recovery of accidental deletions in data records?

Answers

Answer: Data backup

Explanation:

Explanation: Data backup is the practice of keeping files in case of any accidental deletions for restoration

Blake is on the fast track and hopes to get a promotion soon. he wants to make sure that he is always able to
work at peak proficiency on the job. he has done a great deal of work and has numerous essential files that are
crucial to his job. he uses this utility to make sure these files are saved on the office's external hard drive.

a.remote control
b.firewall
c.file compression
d.backup

Answers

Answer:

D

Explanation:

the term used to describe a memory location whose value changes during the program execution is​

Answers

Answer:

variable

Explanation:

A variable is used to store data and can be changed throughout your program.

What makes an operating system the master controller

Answers

Answer:

An operating system is a master control program, which controls the functions of the computer system as a whole and the running of application programs. All computers do not use the same operating systems.

Explanation:

What is the name of the general ledger that tracks all bitcoin transactions?.

Answers

Answer:

The Name of the General Ledger that Tracks all Bitcoin Transactions is Called the Blockchain.

A Blockchain is a Growing List of Records, known as Blocks, that are linked together using Cryptography. Each Block in a Blockchain contains a cryptographic Hash of the Previous Block, a timestamp, and also the transaction Data.

How to give the the crown?
Can show a video if you can or photos!

Answers

Answer:

The crown is called the Brainliest award. If two people had given you answers then there is a option of mark as Brainliest. Click there in the option of mark as Brainliest in which you like the answer most. If any one person has given answer then after some days you will a notification to mark his/her answer as Brainliest. By this you can mark an answer as Brainliest.

Please have a great day, and have fun giving people Brainliest answers <3

A security event popped up, alerting security of a suspicious user gaining access to, and copying files from, the %systemroot%\ntds\ file path on a server. what is the user trying to do?

Answers

There are different kinds of event.  What the user trying to do is to gather employee login credentials.

What is a credential harvester?

Credential Harvesting  is a term that is also called Account Harvesting. This is known to be a type of MITM attacks, DNS poisoning, phishing, etc.

It is often used to gather a lot of high numbers of credentials (such as username /or password combinations) and it is done mainly for reuse.

Learn more about security event from

https://brainly.com/question/25720881

30 POINTS!!!! HELPPPPP!!! in computer science, what does the term inference mean?
a. the wiring connection between the computer and all of its hardware devices
b. an internal switch inside the monitor that dims the screen's brightness at sunset
c. a device or program that allows a user to communicate with a computer
d. a sensor that turns the computer fan on when the computer gets too hot

Answers

Answer:

A. The act or process of reaching a conclusion about something from known facts

Hope this helps you!

Please Mark me Brainlest!!

Answer: c. a device or program that allows a user to communicate with a computer

Explanation:

Which device is used to direct the flow of data on a computer network?

Answers

Answer:

If you like my answer you can mark it as Brainliest.

Explanation:

A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet.

Provide a written response that: describes in general what the identified procedure does and how it contributes to the overall functionality of the program write your response here explains in detailed steps how the algorithm implemented in the identified procedure works. Your explanation must be detailed enough for someone else to recreate it. Write your response here provide a written response that: describes two calls to the selected function. Each call must pass different arguments that cause a different segment of code in the algorithm to execute

Answers

These exercises are about a descriptive essay or a descriptive text. The purpose of a descriptive text is to:

Inform; and guide the reader's precision.

What is a Descriptive Text?

As with every essay or text, your document must have the following:

An introduction (where you state the purpose of the text)The body (where the major description takes place)The conclusion (where you summarize and highlight cautionary instructions).

Usually, it helps to itemize, label, and number instructions.

Examples of Descriptive Texts are:

Standard Operating ManualsCar Manuals.

Learn more about Descriptive Texts at:
https://brainly.com/question/3530147

These activities are about writing a descriptive essay or text. A descriptive text's objective is to, Instruct and direct the precision of the reader.

What is the Definition of Descriptive Text?

The document, like any other essay or literature, must include the following:

a brief overview (where you state the purpose of the text)The body (where the major description takes place)The final word (where you summarize and highlight cautionary instructions).

It is often beneficial to itemize, label, and number instructions. Descriptive texts include the following:

Car Manuals and Standard Operating Procedures

Visit to learn more about Descriptive Texts:

brainly.com/question/3530147

#SPJ4

Other Questions
Consider the scenario in which a man cheats on his partner in a society with community-enforced norms. what do you imagine could happen to the man, given that he is in a society with community-enforced norms rather than a simple reciprocity-based society HELP PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The american bison was once common in the prairie, but now wild bison are rare. Like cows, bison eat grass. What kind of organism is a bison? At 25C, which 5.0 g Zn sample will react the fastest with dilute HC?A)barB)lumpC)powderedD)sheet metal Answer anyone help!!!??? 6. Complete the Spanish sentences using the correct form of the underlined article in the English sentence to agree with the noun it is used with. Use the information from the lesson to complete this section. a. The mother has an apple.____ madre tiene _____ manzana.b. The boy needs some shoes._____ nio necesita _____ zapatos. c. A car needs some new tires._____ carro necesita ______ llantas nuevas.d. The daughters look for the dolls._____ hijas buscan ______ mucas. e. The parents need a break. _____ padres necesitan ____ descanso. Freida tossed a coin 3 times and it always landed on head. Fine the probability of tossing a head. What is the central idea of this text? a) Four friends go on a camping trip in the woods, but one of them gets hurt.b) An injured girl asks for help from some boys she comes across in the woods. c) Three boys help an injured girl as they find a spot in the woods to stay safe from plague-ridden zombies.d) Three boys hide from an injured girl whom they fear will get a plague and become a zombie. What do you think the artist wanted to communicate? What do you see in the artwork that makes you say that?Water LiliesBy Claude Monet J^3 = 0.125 (I dont understand help me please) Which food chain correctly shows the direction that energy and matter can flow through a temperate forest ecosystem?a) fruit > insect > sparrow > hawkb) hawk > fruit > insect > sparrowc) insect > sparrow > hawk > fruit d) insect > hawk > fruit > sparrow why is reproduction necessary? Tom had a homework assignment to graph only the coordinates that would lie in Quadrant Ill of the coordinate grid. Which point below could have been one of the points that Tom graphed? A (-3,-7) B (-2,5) C (1.6) D (5, -13) Question #31 Which expression is equivalent to 35v ? Describe the major e-commerce activities and processes and the mechanisms that support them. A middle school took all of its 6th grade students on a field trip to see a ballet at a theater that has 4500 seats. The students left 3105 seats vacant. What percentage of the seats in the theater were filled by the 6th graders on the trip? According to the reading the causes of the Cold War stemmed from USA & USSR (MARK ALL THAT APPLY) *1 pointhaving political differencesprotecting human rightsdistrusting each otherdisagreeing on the division of Germanyhave a grudge against each other starting back in WWII The metric ruler is typically divided intoa. inches and half inchesb. centimeters and millimetersc. millimeters and decimeters d. eighth inches and sixteenth inches 10 A grocery store bought 1,600 cans ofvegetables in different sizes. Of the cans,25% contained less than 400 grams ofvegetables, 15% contained between 400and 500 grams of vegetables, and therest contained more than 500 grams ofvegetables.How many cans contained more than 500grams of vegetables?F 1,120H 640G 800J 960 Research on pubertal timing indicates that threats to emotional health _____ puberty, whereas threats to physical health ______ it.