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]
2 years ago
13

Lab 6B: printing a binary number

Computers and Technology
1 answer:
r-ruslan [8.4K]2 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
In JavaScript, which of the statements below can be used for string declaration?
Katen [24]
For a string primitive, b. For a String object, d. If we're non-specific, a.
6 0
3 years ago
_____ are used to associate a style sheet or style rule with a specific device or list of device features.â
Usimov [2.4K]
Media queries are used to associate a style sheet or style rule with a specific device or list of device features<span> .This technique is used for delivering a tailored style sheet to different devices and applying </span><span>CSS styles depending on a device's general type, specific characteristics  or environment.
</span>
6 0
2 years ago
Read 2 more answers
Cari brought 2 pounds of grapes at the grocery store she ate 5 ounces of the grapes on way home what is the weight of the grapes
sveta [45]

Answer:

27 ounces

Explanation:

You can convert 2 pounds into 32 ounces then subtract the 5 ounces that she ate from that 32.

7 0
2 years ago
Web services can exchange information between two different systems only if the operating systems and programming languages upon
stich3 [128]
Because if im talking to someone in english but they are from china and communicating to me in chinese then thas what itll do
4 0
2 years ago
A hard drive cannot be partitioned until the device _________ is set.
Elza [17]
Partition(ed) is the answer
8 0
3 years ago
Read 2 more answers
Other questions:
  • The word computer consists of 64 bits, which is equivalent to _____ bytes.
    5·1 answer
  • The manager of a sports club has data about the club members' ages in a workbook. He wants to find which age is most common. Whi
    13·2 answers
  • What are some examples of lighter-than-air vehicles?
    10·1 answer
  • Um can anyone who is really into science and physics answer this question
    7·1 answer
  • In each iteration, selection sort (small) places which element in the correct location?
    9·1 answer
  • It is impossible to use a computer without a mouse. Is this statement true or false?
    10·1 answer
  • What is a benefit of the rise in citizen journalism? Multiple answer choice below
    13·1 answer
  • Complete each sentence
    10·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
  • How do people and computers approach problems differently
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!