Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.
Understanding binary helps you understand the computer a little bit more. Learning your powers of 2 is also a very important skill to have. Today, you will demonstrate your understanding of binary to write a very simple function dealing with binary numbers and powers of 2.
Write a function called largest_power(binary_string)
,
which has one parameter, a string of 1's and 0's. It should return
an integer, the smallest power of 2 that is greater than (or equal
to) the input binary string.
Make sure your program handles all necessary cases gracefully. What additional test cases should you check?
Function Parameters | Sample Output |
---|---|
"0" | 1 |
"1" | 1 |
"11" | 4 |
Submissions for post labs are to be done via the inquire system. Go to http://inquire.roanoke.edu/ You should see a section for post labs. Submit your .py file to the appropriate post lab location.
Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.