directlythe function reads from the keyboard and writes to the screenjust as if it were run as program without redirectionc:\pp \system\streamspython from teststreams import interact interact(hello stream world enter number> squared is enter number> squared is enter number^ bye nowlet' run this function under the control of the redirection function in redirect py and pass in some canned input text in this modethe interact function takes its input from the string we pass in (' \ \ \ '--three lines with explicit endof-line characters)and the result of running the function is tuple with its return value plus string containing all the text written to the standard output streamfrom redirect import redirect (resultoutputredirect(interact(){}' \ \ \ 'print(resultnone output 'hello stream world\nenter number> squared is \nenter number> squared is \nenter number> squared is \nenter number>bye\nthe output is singlelong string containing the concatenation of all text written to standard output to make this look betterwe can pass it to print or split it up with the string object' splitlines methodfor line in output splitlines()print(linehello stream world enter number> squared is enter number> squared is enter number> squared is enter number>bye better stillwe can reuse the more py module we wrote in the preceding (example - )it' less to type and rememberand it' already known to work well (the followinglike all cross-directory imports in this book' examplesassumes that the directory containing the pp root is on your module search path--change your python path setting as needed)from pp system more import more more(outputhello stream world enter number> squared is enter number> squared is standard streams