Question: PYTHON Create a Python class Dice - an instance of this class will return values between 1 and 6, inclusive Create a class Sierpinski with
PYTHON Create a Python class Dice - an instance of this class will return values between 1 and 6, inclusive Create a class Sierpinski with two methods: generate_data() and plot_data() The object Sierpinski is to be constructed as follows a. Take three vertes points in a plane to form a triangle, i.e. [[0,0],[20,20],[40,0]] b. Select point 1,1 inside the triangle as your initial point and consider that your current position. c. Randomly select any one of the three vertex points by calling (rolling) the instance of Dice object: if 1 or 2 comes up, select point [0,0] if 3 or 4 comes up, select point [20,20] if 5 or 6 comes up, select point [40,0] d. Move half the distance from your current position to the selected vertex and make that your current position e. Plot the current position (add all data to lists X and Y, then use matplotlib.pyplot at the end to plot all points after all iterations have been completed) f. Repeat from step c a 1000 times Your main function should look like this: #S = Sierpinski([[P1x,P1y],[P2x,P2y],[P3x,P3y]], number_of_iterations, current_pos_x, current_pos_y) S = Sierpinski([[0,0],[20,20],[40,0]], 1000, 1, 1) S.generate_data() S.plot_data()
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
