< Back

Post Lab 20

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.


One of the uses of binary numbers is to define subsets of a larger set. Today, you will demonstrate you knowledge of binary numbers by writing a function that generates a subset of a given string based off of a binary input.

Details

Write a function called compute_subset(binary_string, masked_string), which has two parameters: a string of 1's and 0's, and another arbitrary string. Both strings must have the same length. It should return a string, the characters from the masked string from the locations that the binary string has a 1. These characters should be in the same order as they appeared in the original string.

Make sure your program handles all necessary cases gracefully. What additional test cases should you check?

Sample Test Cases

Function Parameters Sample Output
"11001", "HELLO" HEO
"10000", "WORLD" W

Submission

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.