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 and three of your friends decide to hike the Appalachian Trail, a 2175-mile trail running from Georgia to Maine, starting wh
kozerog [31]

Answer:

The things to do:

a. Lie down flat.

b. Call your friend on phone to inform him of the situation, if he is not already aware.

c. Instruct him to call the rescue team and a helicopter ambulance.

d. Make a video call to your doctor and ask her for first aid instructions.  She can use HIPAA compliant video-conferencing tools to initiate consultations and treatment with you from the far distance.

e. Follow your doctor's instructions.

Explanation:

Telemedicine is the extension of medical services to patients in remote places.  This practise is facilitated by the use of telecommunication devices and telemedical equipment.  Telemedicine is made possible by technological advancements.  Many healthcare practitioners have embraced the practice and offer their patients telemedical services as the need arises.

Modern technology has enabled doctors to consult patients by using HIPAA compliant video-conferencing tools.

HIPAA stands for the Health Insurance Portability and Accountability Act of 1996, which was enacted by the 104th United States Congress and signed by President Bill Clinton in 1996.  The Act encourages Healthcare access to remote patients, medical consultation and treatment portability, and secures health information, among others.

7 0
3 years ago
What is the storage of a modern hard disk drive?
Alinara [238K]

Answer:

80 gigs of storage

Explanation:

it gives a bunch of room because of the calculations the vomputer

3 0
3 years ago
Find prime no using Java
bonufazy [111]

Answer:

Um

Explanation:

I don't understand

4 0
3 years ago
4. The hard drive is a long-term storage, which means the data is still saved even if you turn the computer off or unplug it. Tr
alina1380 [7]

Answer:

True

Explanation:

A hard drive doesn´t wipe itself after a certain amount of time like RAM does. The data you store on it will stay there until the hard drive is either destroyed, or you delete to the data yourself.

6 0
2 years ago
ASAP
creativ13 [48]
It’s image-permanence. Hope that helps
3 0
2 years ago
Other questions:
  • PC’s & More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
    14·1 answer
  • Match the following tasks with their appropriate timing.
    8·1 answer
  • Template files can contain the following items: text, tables, images and lists.
    10·1 answer
  • Which of the following statements is NOT true about a mainframe computer?
    14·1 answer
  • This is the most flexible way to create a query. Used to create queries that displays only the records that match criteria enter
    12·1 answer
  • Which type of operating system requires a keyboard in order to issue commands?
    13·1 answer
  • How are Action Buttons different than hyperlinks?
    8·1 answer
  • What are the reasonsfor documenting business rules​
    6·1 answer
  • Why is simplicity important in navigation design?
    13·1 answer
  • The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!