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 aspect of web design is Gloria following when she uses the same color
tresset_1 [31]
The answer to this is C
4 0
3 years ago
Read 2 more answers
_______ _____ is the process of creating usable computer pograms and applications and the theories behind those processes. Quest
stepladder [879]
<span>The correct answer is


C. Computer Science</span>
7 0
3 years ago
Read 2 more answers
Learning in a digital environment is also called learning.
aleksandrvk [35]

Learning in a digital environment is also called O<u>nline Learning.</u>

Explanation:

The main difference between the digital learning and the traditional form of learning is that

  • Digital Learning takes place online or virtually.
  • The traditional Learning is conducted in a classroom building.
  • Another factor that differentiate the 2 forms of learning is that the instructor or the trainer may not be present at the real-time but in a traditional training method the trainer or the instructor is present in person
6 0
4 years ago
Read 2 more answers
When you enter a two-digit year that is less than 30, Excel changes the year to _____. Question 7 options:
Fofino [41]
The answer is a. 20xx

when you enter a 2 digit year that is less than 30, excel will assume that it's a 20th century and changes the year to 20xx. To change how excel interpret this, you should select 'assume the 21st century for 2 digit years before' check box
3 0
3 years ago
Hi AllyUbongAbasiEtuk
Ainat [17]

Answer:

not a valid question

Explanation:

4 0
4 years ago
Read 2 more answers
Other questions:
  • CAPTCHAs can be used as a form of signature to create a valid contract in e-commerce. True False
    6·2 answers
  • Where do endnotes appear in a document? at the bottom of the page at the top of the page at the end of the document at the end o
    12·1 answer
  • As the project manager for a software development project, you are helping to develop the project schedule. You decide that writ
    13·1 answer
  • Of the three types of mutating malware, what type changes its internal code to one of a set number of predefined mutations whene
    9·1 answer
  • The sun is a type of what?
    9·1 answer
  • Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The fi
    5·1 answer
  • What is the purpose of the New Window command?
    7·2 answers
  • Write a program that creates a two-dimensional array initialized with test data. Use any data type you wish. Declare a two-dimen
    9·1 answer
  • Which statement correctly differentiates how to use list and table styles?
    12·2 answers
  • A router periodically goes offline. Once it goes offline, you find that a simple reboot puts the router back online. After doing
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!