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
Mariulka [41]
4 years ago
13

Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar

y. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x
Computers and Technology
1 answer:
mylen [45]4 years ago
3 0

Answer:

The program to this question can be described as follows:

Program:

num= int(input('Enter a number: ')) #input value by user

st = '' #defining string variable

while num > 0: #define loop to calculte values binary number

   val= num % 2 # holding remainder (0 or 1) in val variable

   st =st+str(val) # store value in str variable

   num = num//2 #calculte quotient value

print("binary number is: ",st)

Output:

Enter a number: 5

binary number is:  101

Explanation:

Program description as follows:

Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.

In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.

Outside the loop, the print method is used, that prints st variable holds value.

You might be interested in
QUESTION 4 Developing practical thinking skills often involves O using common sense o learning from experience and building emot
Juliette [100K]

Answer:

The answer is "mixing collaboration with private time".

Explanation:

In this question, the development of practical thinking abilities, training often involves resolved everyday struggles. It also helps students, are already used to develop communication skills, in particular, to resolve mostly based on critical thinking, everyday life issues at different layers of difficulty.

8 0
3 years ago
that average july high temperature is 85 degrees fahrenheit in new york, 88 degrees fahrenheit in denver, and 106 degrees fahren
goblinko [34]

Answer:

public class num8 {

   public static void main(String[] args) {

       System.out.println("Average Temperature in New York is 85 degrees fahrenheit");

       System.out.println("Average Temperature in Denver is 88 degrees fahrenheit");

       System.out.println("Average Temperature in Phoenix is 106 degrees fahrenheit");

   // Calculating the new average Temperatures

       System.out.println("The New Average Temperature in New York " +

               "is "+ ((0.02*85)+85 )+ " degrees fahrenheit");

       System.out.println("The New Average Temperature in Denver " +

               "is " +((0.02*88)+88 )+ " degrees fahrenheit");

       System.out.println("The New  Average Temperature in Phoenix " +

               "is "+((0.02*106)+106 )+ " degrees fahrenheit");

   }

}

Explanation:

  1. Using Java first display the previous average temperatures for the three cities as given in the question
  2. Then calculates the new average temperature by multiplying by 0.02, because of a 2 percent increase in the average temperature
  3. Display the new temperature using the System.out,println

8 0
3 years ago
Which of the following ports offers a fast connection that could be used to download and watch your favorite TV shows?
Reil [10]

FireWire

i just saida random one i didnt read it

7 0
3 years ago
The _________ sort usually performs fewer exchanges than the ________ sort.
Makovka662 [10]
The two words that complete the sentence are: selection and bubble.

The complete sentence is: The selection sort usually performs fewer exchanges than the bubble sort.

Both, selection and bubble are sorting algorithms used in computer programs. This is they are procedures to arrange data.

Bubble is the most simple algorithm but it is too slow and impractical, so selecting sort, still simple, performs better than bubble sort.

Selection sort divides the list of data into two parts: one contains the data already sorted and the other has the part of data pending to be sorted.

Bubble sort goes through every pair of elements, compares the two data and moves them if necessary.
3 0
3 years ago
What can you do to help avoid or minimize accident while working at the farm?​
scZoUnD [109]

Answer:

safety first

Explanation:

avoid the narrow materials that cause an accident

3 0
3 years ago
Other questions:
  • How many packets does your computer send/receive in a single mouse click when you visit a website?
    6·1 answer
  • Plz help! 3 questions! 1.The ideal light to use is.... A.front light B.a combination of side and back light C.a combination of f
    10·1 answer
  • You can use this effect to break a color into a percentage of its full strength.
    13·1 answer
  • Before guis became popular, the _______________ interface was the most commonly used.
    15·1 answer
  • Research: "How was your experience on site '4chan'?"<br><br> Please answer in the box below.
    9·1 answer
  • A palindrome is a word or phrase that reads the same both backward and forward. The word ""racecar"" is an example. Create an al
    15·1 answer
  • ____ is the security guarantee that people who intercept messages cannot read them. A. Availability B. Encryption C. Confidentia
    9·1 answer
  • Some machine/items/gadget having only hardware​
    8·1 answer
  • What is the computer software? Does a hardware can work without software?
    7·2 answers
  • What does angularfirestoremodule. Enablepersistence() do.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!