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
kaheart [24]
3 years ago
13

Lab 6B: printing a binary number

Computers and Technology
1 answer:
r-ruslan [8.4K]3 years ago
7 0

Answer:

In Python:

num = int(input("Enter a decimal integer: "))

temp = num

bin = ""

while num > 0:

   bin = str(num%2)+bin

   num//=2

print(str(temp)+" in binary is "+str(bin))

Explanation:

This prompts the user for a decimal number

num = int(input("Enter a decimal integer: "))

This assigns the input number to a temporary variable

temp = num

This initializes the binary output to an empty string

bin = ""

This loop is repeated while num is greater than 0

while num > 0:

This appends the remainder of num divided by 2 to the front of the binary variable bin

   bin = str(num%2)+bin

This calculates the floor division of num and 2

   num//=2

This prints the required output

print(str(temp)+" in binary is "+str(bin))

You might be interested in
Why was the microchip essential to improving computers?
-BARSIC- [3]
Because it downsized the scale of the computer itself.

5 0
3 years ago
select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
ivanzaharov [21]

Answer:

screen - soft cloth

keyboard - paintbrush

6 0
2 years ago
Create a Trip class. Include as data members destination, distance traveled, total cost of gasoline, and number of gallons consu
Luba_88 [7]

The answer & explanation for this question is given in the attachment below.

Download docx
4 0
3 years ago
Why is there more than one Brainly website?
marta [7]

they are for different countries and languages

8 0
3 years ago
Read 2 more answers
If a data label, title, or legend in a chart is difficult to read, you can format them as bold, but you cannot change the font s
Daniel [21]

If a data label, title, or legend in a chart is difficult to read, you can format them as bold, but you cannot change the font size: False.

<h3>What is a chart?</h3>

A chart can be defined as an effective medium that is used to graphically display data in a pictorial form. Thus, a chart comprises the following elements:

  • Data label
  • Title
  • Legend

If the aforementioned elements in a chart is difficult to read for the end users, they can easily format them as bold and equally change the font size.

In conclusion, the elements in a chart can be formatted as bold and their font size can also be changed.

Read more on chart here: brainly.com/question/24741444

8 0
2 years ago
Other questions:
  • A technician is troubleshooting a small network with cable Internet service in which a user is receiving a message in her web br
    15·1 answer
  • Given 3 floating-point numbers. Use a string formatting expression with conversion specifiers to output their average and their
    14·1 answer
  • Which would take more storage space, a layer file showing all the us counties or a layer file showing all the us states?
    8·1 answer
  • When using Regedit to browse through the registry, the key that is highlighted is the ________, and its value entries are visibl
    5·1 answer
  • Suppose you can access the caches in the local DNS servers of your department. Can you propose a way to roughly determine the We
    14·1 answer
  • Write an application that displays the strings in the provided array alphabetically in ascending order.
    9·1 answer
  • Good Morning! Please Help!
    15·1 answer
  • Which information can you apply to every page of your document with the page layout options?
    9·1 answer
  • Under the Home tab, controls for aligning text and objects can be found in the
    5·2 answers
  • Which item was key to how Microsoft got its start in the 1970s? a. artificial intelligence b. vacuum tubes c. Altair 8800 d. UNI
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!