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]
3 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]3 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
What is the difference between second generation and third generation​
Eduardwww [97]

These were later renamed to "Specialized Technology" and "Simscape Components" to help explain this difference.

Specialized Technology (Second Generation) is a Simulink based library and has been around for longer. It can still connect to Simscape, but in the same way you can connect Simulink models to Simscape -- that is, you need converters and sometimes to break algebraic loops, etc. It also has more dedicated electrical power systems capabilities. If your model will be only power systems, and especially if it's a larger model, I'd recommend this one.

Simscape Components (Third Generation) is built using the Simscape language and therefore connects directly with other Simscape blocks. If you plan to use other Simscape domains like mechanical, hydraulic, etc. I'd recommend this one.

4 0
2 years ago
You notice that somehow you have duplicate records for some of your clients in your database. What should you do?
IRINA_888 [86]

Inspect them and make sure that they are exact copies then delete one if they are the same.

5 0
2 years ago
Read 2 more answers
Timur was making a presentation regarding how attackers break passwords. His presentation demonstrated the attack technique that
kakasveta [241]

Answer:

The answer of the following question is Brute force attack .

Explanation:

A brute force attack is the error and trial method that is used by an application program to decode the encrypted data like passwords or the Data Encryption Standard (DES) keys, which through an exhaustive effort (by using brute force) rather than the employing an intellectual strategies.

7 0
2 years ago
A shopaholic has to buy a pair of jeans , a pair of shoes l,a skirt and a top with budgeted dollar.Given the quantity of each pr
Rasek [7]

Answer:

hfjgyyitjtjjtjtj*jj*jtjtjthrhrhfhffbf

4 0
3 years ago
How much should I borrow on a direct loan
olga_2 [115]
I recommend between $5,500 and $12,500 each year.
7 0
2 years ago
Other questions:
  • What is a block cipher algorithm that operates on 64-bit blocks and can have a key length from 32 to 448 bits?
    8·1 answer
  • Which device on a network performs network address translation?
    8·1 answer
  • If you “bury” a story on Digg, what have you done
    10·1 answer
  • Create a function generateString(char, val) that returns a string with val number of char characters concatenated together. For
    11·2 answers
  • Prepare a risk assessment report (RAR) with information on the threats, vulnerabilities, likelihood of exploitation of security
    14·1 answer
  • In information systems, _____ is information from a system that is used to make changes to input or processing activities.
    6·1 answer
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • Video-sharing sites such as youtube and vimeo provide a place to post short videos called clips, true or false?
    10·1 answer
  • I'm getting an iphone xr today. what should i do 1st? Any cool fetures? i have a iphone 6 now so its a pretty big upgrade
    13·2 answers
  • Mention any
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!