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
What setting in Word keeps single lines of a new
Gre4nikov [31]

Answer:

C (Window/Orphan control)

Explanation:

An "orphan" in formatting is a single line of text that is left alone/separated from the rest of the paragraph. Orphan control prevents this from happening by keeping lines together.

3 0
3 years ago
At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase
Alina [70]

Answer:

  1. var projected_fee = 6000;  
  2. for(var i = 1; i <= 5; i++){
  3.    projected_fee = projected_fee * 0.02 + projected_fee;
  4.    console.log("$" + projected_fee.toFixed(2));
  5. }

Explanation:

Firstly, create a variable, projected_fee, and set the initial tuition fee value to it (Line 1).

Next, user a for loop that run for 5 times to repeatedly calculate the projected_fee based on 2 percent of increment rate (Line 4) and display the projected fee to console terminal (Line 5). The output should be

$6120.00

$6242.40

$6367.25

$6494.59

$6624.48

8 0
3 years ago
Which of the following is a way to prevent wastes from contaminating the environment? A) Use absorbent pads to collect floor was
Firlakuza [10]

Answer

Dispose of absorbents as hazardous waste in its own hazardous waste container

Explanation

Hazardous waste is a waste that has chemical composition and properties which makes it capable of causing illness, death  or harm to humans and other life forms when released to the environment without proper management. The characteristics of such wastes include: toxic, ecotoxic, infectious substance, poisonous, explosive and flammability. Hazardous wastes can be destroyed by incineration, chemical process, and temporary on-site waste storage facilities such as waste piles and lagoons/ponds



8 0
3 years ago
Read 2 more answers
Dragging or sizing affects only a ____.
il63 [147K]
<span>Dragging or sizing affects only a "Selected Object." For example, an image, you need to click the image in order for you to select that image. The image is considered as an object. From the time you click on the picture, there are points visible where you can click and drag upon it nor resize.</span>
7 0
3 years ago
Jessica wants to purchase a new hard drive. She wants a drive that has fast access because she will use it to edit videos on her
professor190 [17]

Answer:

7200 RPM magnetic HDD

Explanation:

This gives her all the benefits of the above mentioned.

6 0
3 years ago
Other questions:
  • A storyboard is an example of an implementation tool.<br><br> A.<br> True<br><br> B.<br> False
    8·2 answers
  • Application partitioning gives developers the opportunity to write application code that can later be placed on either a client
    7·1 answer
  • If anything is changed on an already-tested module, regression testing is done to be sure that this change hasn’t introduced a n
    13·1 answer
  • Your company runs several databases on a single MySQL instance. They need to take backups of a specific database at regular inte
    12·1 answer
  • Three of the most important jobs of security management are to ensure _____ are organized according to sensitivity, ensure that
    10·1 answer
  • Unwanted email sent to large groups of people who did not request the communication is called _____
    12·1 answer
  • What is the relationship between agile teams and project requirements
    9·1 answer
  • The purpose of Appetizers on the menu​
    6·2 answers
  • the ghost adventures team uses a variety of tools and technology in investigations. which one is described as an adjustable freq
    9·1 answer
  • Will economists be replaced by artificial intelligence?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!