import matplotlib.pyplot as plt import math, cmath def plotc(zs): xs=[z.real for z in zs] ys=[z.imag for z in zs] plt.plot(xs,ys) def path(z,s): zs=[z] phase=0 pos=z for c in s: if c=='L': phase+=math.pi/2 if c=='F': pos+=cmath.rect(1,phase) zs.append(pos) return zs def O(z): s='LFFLFLFFLF' zs=path(z,s) plotc(zs) O(2) plt.show()