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
What is one disadvantage people face without a checking account?
sveticcg [70]

Answer:

If they have a job that only pays with ckecks they won't be able to have their paycheck.

Explanation:

8 0
3 years ago
Where do we draw the line between creativity and deception?
BARSIC [14]

Answer:

when you are manipulating the pictures for art and creativity purposes and not for changing your own or others appearance.

4 0
3 years ago
You created an outline within a worksheet. what does the button indicate to the left of a row heading?
cricket20 [7]
<span>Business Name (default field), State (correct field)</span>
3 0
3 years ago
8.9 code practice edhesive
nadezda [96]

Answer:

.

Explanation:

7 0
3 years ago
Andy uses a dial-up modem to connect to the Internet. He usually browses news sites, but he notices that online video takes a lo
Korvikt [17]
The answer is C. The modem does not contain enough bandwidth to handle modern video streaming.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Add is a function that accepts two int parameters and returns their sum.
    8·1 answer
  • Joe always misspelled the word calendar what function corrects the word
    12·2 answers
  • Which of the following is true of Chinese Opera: Two opera centers emerged Beijing and Yangzhou 300-400 forms of opera arose in
    10·1 answer
  • A(n) __________ is a server with the original copy of the data that others need.
    12·1 answer
  • In the program below, numA is a _____.
    8·2 answers
  • Monster Collector
    7·1 answer
  • Which of the following images illustrates safe driving?
    8·2 answers
  • Which Internet connection type tends to use shared bandwidth?<br> Cable<br> Dial-up<br> DSL<br> ISDN
    5·2 answers
  • What does the Finder do?
    5·1 answer
  • 2.Some artists look for ways to extend copyright for longer than the laws normally allow. Why do they do this?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!