Please rephrase the code starting from the # Use Python 9.3.7…
Question Answered step-by-step Please rephrase the code starting from the # Use Python 9.3.7… Please rephrase the code starting from the #Use Python 9.3.7 chaos_game(p0, w, f, inum)Inputs:p0: initial point (x0,y0)w: weights for random selection among ff: list of affine transformationsinum: number of iterations / points”””# chaos_game: generate the pointsdef chaos_game(p0, w, f, inum):# 1. initialize empty list of points for each transformp = [[] for _ in range (len(f))]# 2. initialize current point cp as initial point p0cp=p0# 3. repeatedly select next point using last point as inputfor _ in range ( inum ): # 3a. chooses a random index ir using weights w ir = np.random.choice (range(len( f )), p=w ) # 3b. update cp using the corresponding transform cp = f[ir]. transform ( cp ) # 3c. append cp to the appropriate list of points p[ir].append(cp)# 4. return pointsreturn p Computer Science Engineering & Technology Python Programming ECE 105 Share QuestionEmailCopy link Comments (0)


