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
Caden, Jacob, Lucas, and Michael, whose last names are Armstrong, Boothe, Gardner, and Robinson, live in four houses in a row.
Anit [1.1K]

Answer:

Jacob Gardner - Lucas Robinson - Caden Boothe - Michael Armstrong

Explanation:

According to clue 4, Lucas's house is not the first, and he has a house on his right, so it can only be house 2 or house 3. Therefore, Caden's house (which is on the right right of Lucas's), it can only be house 3 or house 4.

In turn, track 1 says that Michael's house is not next to Lucas's, so it can be 1 (if Lucas's house is 3) or 4 (if Lucas's house is in 2).

Track 2 says that there is a house before Michael's, which eliminates the possibility that Michael's house is number 1 (there would be no previous house). Thus, in addition, Lucas's house turns out to be 2 (Michael's house is not next door) and Caden's is 3, while Jacon's is house 1.

Jacob - Lucas - Caden - Michael

In turn, regarding surnames, clue 2 says that Robinson's house is after Gardner's and before Michael's. Thus, Robinson can be the last name of Jacob or Lucas, and Gardner that of Lucas or Caden. Now, since Boothe's house is just before Armstrong's, the order would be as follows:

Jacob Gardner - Lucas Robinson - Caden Boothe - Michael Armstrong

4 0
3 years ago
The area around the outside of the page where normally no text or images appears is called the ______.
SSSSS [86.1K]
The answer should be A, I'm unsure how to explain this to you, sorry, but I hope you remember this for future reference
6 0
3 years ago
Name the cell range selected in the given worksheet? <br>plzzz helppppp​
Monica [59]

Answer:

B2:E6,,,,,,,,,,,,,,,,

6 0
2 years ago
When you respond to an e-mail message, a good skill to develop is ___________-editing, which involves inserting your responses t
Drupady [299]

Answer: Down editing

Explanation:

Down editing is a method of replying emails which allows you to respond point by point to an email. It add certainty, precision and quality to your response and helps prevent misunderstanding of email response.

7 0
2 years ago
Two input capture events occur at counts 0x1037 and 0xFF20 of the free-running counter. How many counts, in decimal have transpi
Gnom [1K]

Answer:

The correct answer is C.

Explanation:

You have to do 0xFF20 - 0x1037 but first, you need to convert the counts from hexadecimal base system to decimal base system using this formula:

N = x_{1} * 16^{0} + x_{2} * 16^{1} + x_{3} * 16^{2} + x_{4} * 16^{3} + ... + x_n 16^{n-1}, where position of the x₀ is the rightmost digit of the number.

<em>Note: </em>

  • A = 10.
  • B = 11.
  • C = 12.
  • D = 13.
  • E = 14.
  • F = 15.

0xFF20 = 15*16³+15*16²+2*16¹ = 65312

0x1037 = 1*16³+3*16¹+7*16⁰ = 4151

Result: 65312 - 4151 = 61161

4 0
3 years ago
Other questions:
  • Get these points why they hot!!!!!!!!!!!!!!!!!!!!
    14·2 answers
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • What is a many-to many types of correspondence?
    5·1 answer
  • A database stores a large amount data in vertical ___
    10·1 answer
  • CODE EXAMPLE 3-1 SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors INNER JOIN invoices ON vendors .vendor
    13·1 answer
  • Which of the following is the most significant outcome of the formation of the SMPTE?
    15·1 answer
  • It is necessary tto save updates often when working in google docs? True or false
    11·2 answers
  • Write a C++ program that consist
    5·1 answer
  • In which generation of computers are we in?​
    9·1 answer
  • Which tool ia used to create the world wide web?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!