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
iren2701 [21]
3 years ago
12

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 modulo 2 (remainder is either 0 or 1) Assign x with x divided by 2
Computers and Technology
1 answer:
Mashcka [7]3 years ago
6 0

Answer:

Following are the code to this question:

def binarynumber(num):#defining a method binarynumber that accepts a parameter num

   x=""#defining a string variable x

   if (num!=0):#defining if condition to check number not equal to 0

       while (num>=1):#defining a loop that check value is grater then equal to one

           if (num %2==0):#defining if condition to check num is even

               x=x+"0" #add string value 0 in num variable

               num=num/2 #divide the value by 2

           else:#defining else block

               x=x+"1"#add string value 1 in num variable

               num=(num-1)/2#first subtract 1 into num variable then divide the value by 2

   else:

       x="0"#assign string value 0 in num variable  

   return "".join(reversed(x))#return value

num = int (input ("Enter any number: "))#defining num variable that input the integer value

print (binarynumber(num))#using print method to call method binarynumber with passing num parameter

Output:

Enter any number: 12

1100

Explanation:

  • In the above python code a method "binarynumber" is declared, in which the "num" variable passes as the parameter inside the method a string variable "x" is declared that stores all converted values.
  • Inside the method and if the block is declared that checks number value is not equal to 0 if this condition is false then it will add string value and reverse its value.
  • Or if the condition is true it defines a while loop that calculates the given number binary digits and returns its value.
  • At the last step, the num variable is declared that inputs the integer value from the user end and calls the method by using the print method.    
You might be interested in
"You are setting up a new subnetwork on an existing network. Management has asked that you use existing cabling that the company
NemiM [27]

Answer:

T10BASE-T networks require a minimum of Category 3 cable and connection hardware for proper operation.

Explanation:

The characteristics of this cable:

1. Complies with EIA / TIA - 568-B ISO / IEC 11801 Class C

2. 0.51 mm (24 AWG) solid copper conductor

3. PE (Polyethylene) insulation,

4. PVC outer cover,

5. no flame propagator and

6. self-extinguishing.

7. Twisted pair

8. SUITABLE FOR VOICE AND DATA INSTALLATIONS FROM 10Mbps to 16Mbps.

<u>It is suggested to buy the complete coil to change the wiring gradually. </u>

7 0
3 years ago
you are packing a mobile phone containing a lithium ion battery and you get a prompt on the screen to put a lithium ion label on
ss7ja [257]

Answer:

<u>Do not use such labels because they may be misleading and are unethical.</u>

Explanation:

Note, there is a<u> big difference in design</u> between the two terms or labels. Lithium metal batteries are <u>non-rechargeable batteries.</u> In other words, they cannot be recharged after they run down. For example, most <em>watches, calculators, or car keys are made of </em>lithium metal batteries.

While Lithium-ion batteries (or Li-ion batteries) are <u>rechargeable batteries</u> , and they are commonly used by<em> mobile phones, laptops, and other gadgets.</em>

<em>Therefore, </em>with such differences in mind, it may be very misleading when someone in possession of the mobile phone sees the lithium metal labels; then thinks the battery is non-rechargeable.

8 0
3 years ago
Which command would you use to swap the words hither and yon on any line with any number of words between them? (You need not wo
REY [17]

Answer:

The command i will use in carrying out such function is

Explanation;

Kindly check the attached file for the command as it can not be written fully in the answer box.

3 0
3 years ago
Discussion Six: Code of Ethics IT workers have many different relationships, including those with employers, clients, suppliers,
tia_tia [17]

An ethical issue that IT organizations face today is that of being able to illegally download software or files that should not be legally available, or that should not be downloaded for free. This poses an ethical problem, as dowloading these items illegally would greatly benefit the IT company economically. However, the company is required to ignore the availability of such material and instead abide by the law.

An example of this in my personal life is that of dowloading illegal music. As I am aware of the fact that dowloading music for free from illegal sites is against the law, I have taken the responsibility of not doing it. However, this requires me to control or moderate my behaviour, as I know that I have the skills and the financial incentive to act in this way. I have to remember that, although I have the skills to do so, I do not have the right to abuse the systems or the data that I have access to.

5 0
3 years ago
If Word finds a potential error in a document, a red, green, or blue wavy underline flags the problem.
dlinn [17]
As for this problem of true or false, the most probable answer the most likely one to be the correct answer would be A. True.

In Microsoft Word, or commonly referred to as MS Word, or simply Word itself as what is utilized in the problem, the program has the ability to recognize in spelling and grammar. When a red wavy underline is present, the word or words above it are usually wrong in spelling. Though this can be corrected by the user by adding the word in the dictionary so as not to be corrected in the future. The green one would be more about grammar. The blue wavy underline would indicate a word spelled correctly, but might be misused in the sentence it belongs. This usually happens to words that are almost identical in spelling like too and to.
8 0
3 years ago
Other questions:
  • The EPA requires the use of precise forms called ?
    14·1 answer
  • During an experiment, if you purpose change the temperature to test a hypothesis the temperature is called what??
    6·1 answer
  • The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
    5·1 answer
  • After conducting interviews with several bad candidates, Althea, a manager at Langrover Inc. interviewed a candidate who was bet
    15·1 answer
  • Create a script that will determine how many of each currency type are needed to make change for a given amount of dollar and ce
    8·1 answer
  • What are stored procedures? What kind of attack do stored procedures protect from? Identify two reasons why stored procedures ar
    14·1 answer
  • What type of databases is not limited by the data’s physical location?
    7·1 answer
  • How do i delete cookies on a chromebook?
    8·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
  • What are the features of the title bar for the Microsoft word application?​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!