Question

Transcribed Image Text:hideshow
Write a function hideshow that accepts two string arguments, an input string and a masking
string. The masking string is a string consisting of '0's and '1's that has the same length as the
input string. The function then returns a new string that is the same as the input string, except
that it is masked. That is, in any position where the masking string contains a '0' the input
character is replaced by a '#', whereas if the masking string contains a '1', the character is
unchanged. Sample usage:
>>> hideshow('apple', '11001')
'ap##e'
>>> hideshow('apple', '00000')
'#####'
>>> hideshow('apple', '11111')
'apple'
>>> hideshow('abcdefghijklmnopqrstuvwxyz', 13*'01')
'#b#d#f#h#j#1#n#p#r#t#v#x#z'
>>> hideshow 'df###re##', '101010101' )
'd#####e##'
>>> hideshow( 'df###re%%', '101010101' )=='d#####e##'
True
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- Pythonarrow_forwardLab Activity for the students: Exercise 5: Write a program that asks the user to input a letter. The program finds and prints if the letter is uppercase or lowercase. Then, the program asks the user to input a string and get a three-character substring from the beginning of the string. (1 Mark ) Example : If the inputs are 'y' and "Community". Then, the program will print: y is lowercase The substring is: Comarrow_forwardWhat characters are used as delimiters when null is passed as an argument to the Split method of a string object?arrow_forward
- String: abcdefghijklmnopqrstuvwxyzyxwvutsr qponmlkjihgfedcba Make a program that: reads a letter from standard input print the above string up to this letter For example, if the letter was c, the output would be: abcba Must use a function and Pythonarrow_forward// Write a function that takes 1 argument, a string. // It returns true if the string is a palindrome (the same forwards and backwards). // It returns false if the string is not a palindrome. const isPalindrome = (string) => { // your code here... // Examples isPalindrome("cat") // returns false //isPalindrome("level") // returns true }arrow_forwardC PROGRAMarrow_forward
- c++ progamming Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is:arrow_forwardAim: Read a string, S and print its integer value. If S cannot be converted to an integer, print Bad String. ''' # getting the input S = input().strip() try: # if it's possible to convert the entered string into an integer then this block will execute print(int(S)) except: # if it's not possible, then this block will be executed print('Bad String') ''' COMPLEXITY: Time Complexity -> O(1) Space Complexity -> O(1) Sample Input 1: 3 Sample Output 1: 3 Sample Input 2: SB Sample Output 2: Bad String Explaination: '3' as a string can be converted into the integer 3, whereas SB can't be converted to an integer hence the 'except' block is executed and 'Bad String' is printed.arrow_forward
arrow_back_ios
arrow_forward_ios