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.
Details
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?
Sample Test Cases
| Function Parameters | Sample Output |
|---|---|
| "0" | 1 |
| "1" | 1 |
| "11" | 4 |
Submission
Submit your program as a .py file on the course Inquire page before class on Wednesday October 22nd.