angelcruces7885 angelcruces7885
  • 08-11-2017
  • Computers and Technology
contestada

Write a program that responds to a positive integer passed on the command line with the number of bits needed to express that number in binary.

Respuesta :

rsmith6559
rsmith6559 rsmith6559
  • 09-11-2017
You may want to rephrase the output.

```
#!/usr/local/bin/python3

### Written for Python version 3! ###

import sys

num = int( sys.argv[ 1 ] )
exp = 0

while( num > 2**exp ):
    exp += 1

print( "It takes %d bits to get to the center of a Tootsie Roll" % exp )

exit( 0 )
```


Answer Link

Otras preguntas

what is aas congruence?
you hav designed a picture that is shaped as a square. the dimensions of your picture  are 6x6in. you want to make it into a poster with dimensions 13x13in. the
determine whether the system of linear equations has one and only one solution, infinitely many solutions, or no solution. Find all solutions whenever they exis
What did the Egyptians call the area that we now call Sudan?
7 - 3 ( 5t - 10 ) = 67
Find the LCM of 8,9, and 12
What are the sides of the DNA ladder made of?
What did the Egyptians call the area that we now call Sudan?
Find the LCM of 8,9, and 12
determine whether the system of linear equations has one and only one solution, infinitely many solutions, or no solution. Find all solutions whenever they exis