Ex8
This was reasonably straight-forward given the quine.
def apply(f): l = chr(123) # opening curly bracket r = chr(125) # closing curly bracket q = chr(39) # single quotation mark n = chr(10) # linebreak z = [n+" ", l+f"z[i]"+r+q+n+" + f"+q] x = [n+" ", l+f"x[i]"+r] e = [q, l+"e[i]"+r+q+")"+n+" print(f(sourcecode))"] sourcecode = "" for i in range(0,2): sourcecode += (f'def apply(f):{z[i]}' + f'l = chr(123) # opening curly bracket{z[i]}' + f'r = chr(125) # closing curly bracket{z[i]}' + f'q = chr(39) # single quotation mark{z[i]}' + f'n = chr(10) # linebreak{z[i]}' + f'z = [n+" ", l+f"z[i]"+r+q+n+" + f"+q]{z[i]}' + f'x = [n+" ", l+f"x[i]"+r]{z[i]}' + f'e = [q, l+"e[i]"+r+q+")"+n+" print(f(sourcecode))"]{z[i]}' + f'sourcecode = ""{z[i]}' + f'for i in range(0,2):{x[i]}sourcecode += (f{e[i]}') print(f(sourcecode))
Ex8
This was reasonably straight-forward given the quine.