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
Mariulka [41]
3 years ago
13

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
Computers and Technology
1 answer:
mylen [45]3 years ago
3 0

Answer:

The program to this question can be described as follows:

Program:

num= int(input('Enter a number: ')) #input value by user

st = '' #defining string variable

while num > 0: #define loop to calculte values binary number

   val= num % 2 # holding remainder (0 or 1) in val variable

   st =st+str(val) # store value in str variable

   num = num//2 #calculte quotient value

print("binary number is: ",st)

Output:

Enter a number: 5

binary number is:  101

Explanation:

Program description as follows:

Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.

In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.

Outside the loop, the print method is used, that prints st variable holds value.

You might be interested in
When the tv was created (year)
nikitadnepr [17]

Answer:

1927

Explanation:

6 0
3 years ago
Read 2 more answers
A cookie is.... a. an illegal use of information about a customer b. a feature of a Web site designed to attract children c. a f
Elodia [21]

Answer:

C. A file that a Web site stores on a visitor's computer

Explanation:

Have a nice day! :)

3 0
2 years ago
Moore’s law describes the pace at which ______ improve.
iren2701 [21]

Answer: CPUs

Hope it helps :) and let me know if you want me to elaborate.

7 0
3 years ago
What is the fifth and final stage in the process of media production?
Monica [59]

Answer:54

Explanation:

8 0
3 years ago
What should you call a person who has permission to bypass the security of a computer to access it
Sav [38]

Answer:

Administrator

Explanation:

Such permission to bypass the security of a computer to access it is being given to only the administrator. No other user is allowed to have such privileges. And there is only one administrator in a team, and this is the standard as only then the security of a network of computers, and a particular computer can be ensured. And the correct answer to this question is certainly the Administrator.

7 0
3 years ago
Other questions:
  • What does software alone enable a computer to do? connect to the Internet control processing speeds interact with the user manag
    11·2 answers
  • You friends parents are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    10·1 answer
  • What is not true about contracts?
    12·2 answers
  • How can you tell if your car is overheating?
    12·2 answers
  • 1. What makes discrimination different from harassment? (Don't give me definitions.)
    5·1 answer
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    15·1 answer
  • How to convert 23.125 to binary (Hex) using the double - precision representation
    6·1 answer
  • graham drove 39 2/3 miles in 1 1/3 hours. What is the unit rate for miles per hour? Use a pencile and paper. Describe a situatio
    10·1 answer
  • What type of network would be suitable for linking all computers in a building
    6·1 answer
  • 5.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!