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
True or false? To help improve SEO, your URL should match the title of your blog post, word for word.
Vsevolod [243]

Improving SEO, by ensuring the URL matches the title of your

blog post, word for word is False.

<h3>What is SEO?</h3>

This is referred to as Search engine optimization. It is used to

improve a site by ensuring that is more visible when people

search for certain things or words.

The URL should contain only key words and unnecessary ones

should be eliminated which is why it isn't compulsory for the title

to be word for word.

Read more about Search engine optimization here brainly.com/question/504518

7 0
2 years ago
A web designer is creating a web site and wants each browser to resize the text size to look the same in each device. what measu
adelina 88 [10]
The designer could use the measurements in pixels. 
4 0
3 years ago
What is the best way to use a prototype to better understand yolir audience?
9966 [12]
I would say A. Test it and receive feedback
6 0
2 years ago
In full verbatim, a person wants to say that they admitted him to a hospital last month. He makes a mistake about the date and q
MA_775_DIABLO [31]
He should cancel the date and move to another country semis how he screwed up his work, hope this helped
3 0
2 years ago
What is software?
bogdanovich [222]

Answer:

B

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • What does a professional programmer usually do first to gain an understanding of a problem?
    12·2 answers
  • When CPU failed what will happen?
    10·1 answer
  • Which of these is not the correct method for moving text in a document in Word 2016?
    14·2 answers
  • Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the p
    12·1 answer
  • Heres a meme<br><br>free pints as well, because why not.​
    10·2 answers
  • Need help with a program to search to sort elements in an array.(increasing or decreasing order)
    8·1 answer
  • Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a/b, in which a and b a
    11·1 answer
  • Creating a Numpy Array
    5·1 answer
  • LCD, EL and gas-plasma are types of flat-panel screens.<br> True<br> False
    13·1 answer
  • Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!