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 would happen to life on earth if the ozeon layer was not present?
labwork [276]
People would get skin cancer very easily, plants would start to die off, water would start to evaporate, and the world would be in danger.
6 0
3 years ago
Read 2 more answers
A computer hard disk starts from rest, then speeds up with an angular acceleration of 190 rad/s2 until it reaches its final angu
Nataly_w [17]
The first thing we are going to do is find the equation of motion:
 ωf = ωi + αt
 θ = ωi*t + 1/2αt^2
 Where:
 ωf = final angular velocity
 ωi = initial angular velocity
 α = Angular acceleration
 θ = Revolutions.
 t = time.
 We have then:
 ωf = (7200) * ((2 * pi) / 60) = 753.60 rad / s
 ωi = 0
 α = 190 rad / s2
 Clearing t:
 753.60 = 0 + 190*t
 t = 753.60 / 190
 t = 3.97 s
 Then, replacing the time:
 θ1 = 0 + (1/2) * (190) * (3.97) ^ 2
 θ1 = 1494.51 rad
 For (10-3.97) s:
 θ2 = ωf * t
 θ2 = (753.60 rad / s) * (10-3.97) s
 θ2 = 4544,208 rad
 Number of final revolutions:
 θ1 + θ2 = (1494.51 rad + 4544.208 rad) * (180 / π)
 θ1 + θ2 = 961.57 rev
 Answer:
 the disk has made 961.57 rev 10.0 s after it starts up
3 0
3 years ago
Read 2 more answers
Corona and app inventor can be used to develop ________.
Sidana [21]
<span>Corona and app inventor can be used to develop apps for smartphones. Corona can be used to build both games and apps from major platforms like iOS, Android, Kindle, Apple TV, Android TV, macOS, and Windows. App Inventor was originally provided by Google and is now maintained by MIT.</span>
3 0
3 years ago
When one method calls another, which of the following statements are true?
jonny [76]

Answer:

I. The class methods and instance methods of one class may call the public class methods of another class using dot notation and referencing the name of the other class.

Explanation:

Private methods are being accessed from only within the class or scope specified. No other means of accessibility is possible, and even through inheritance. And instance methods can never call without using dot notation, any of the class method of the same class. Hence second and third options are not correct. And the class method and the instance methods of one class may call the public class methods of another class using the dot notation and referencing the name of the other class. Hence, the correct option is the first one.

3 0
3 years ago
File names should describe what is in the file in a few words
JulijaS [17]

Answer

File names should describe the content of the file.

Explanation

File names are set of words  which are used to uniquely identify computer files which are stored in a file system. This helps one to know the contents of the file which you want to find. When you name these file names you use necessary characters you use descriptive words so that you dont have hard times when searching for them. The naming also is determined by the file system you are using because different systems impose different restrictions on the length of the file names and the allowed characters within file names.

3 0
3 years ago
Other questions:
  • Which change signaled a musical progression toward rock and roll?
    14·1 answer
  • Drag the correct type of update to its definition.
    5·1 answer
  • Suppose you wanted to run a web server or ftp server from your home. what type of ip address would you want?​
    6·1 answer
  • Can you please help on number 1 and 2?
    13·1 answer
  • Use the following global structure declaration as an example only. You will need to create your own data structure based on a da
    5·1 answer
  • The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
    12·2 answers
  • Rule- based systems are subset of expert systems true or false?
    7·1 answer
  • Which of the following is a type of input device?
    5·1 answer
  • What's the best item in the binding of isaac?
    13·1 answer
  • The files in James's computer were found spreading within the device without any human action. As an engineer, you were requeste
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!