CPSC120A
Fundamentals of Computer Science I

Post-lab 20

Base Conversion

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

Submit your program as a .py file on the course Inquire page before class on Friday October 24th.