# Lab_5_Exercise_1_Problem_2 # b) # Write a more general version of printString( ), i.e., a function that takes a # string as a parameter. In doing so, we are using the generalisation guideline. def printString(theSpam): print(theSpam) return # Then, using the composition guideline, create another function called printTwice() # that prints the string twice by calling our new and more generalised version of printString(). # The body of this function printTwice() must only have two statements + the return statement. def printTwice(theSpam): printString(theSpam) printString(theSpam) return # Main printTwice("Testing the generalised version of printString( ).") # What is being generalised? # The function printString( ) # How are we generalising it? # We are making it more general by adding a parameter to it: the string to be printed. # This way, the function is more flexible: it can print whatever string we passed to it # as opposed to only printing "spam" (see a) ).