Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is what i have so far on my programming homework in python using only import graphics but im stuck. this is what i have
this is what i have so far on my programming homework in python using only import graphics but im stuck. this is what i have so far.
from graphics import * # Open a graphics window # Set relevant parameters rows = 10 cols = 10 size = 100 p1 = 0 p2 = 0 win = GraphWin(title="ColorGrid", width= size * cols, height= size * rows) win.setBackground(color_rgb(255,255,255)) win.setCoords(0,0 , 10, 10) for i in(0,rows): color=Rectangle(Point(0,0),Point(1,1)) color.setFill(color_rgb(255,0,0)) color.draw(win) win.getMouse()Develop a Python program (called colorgrid.py) that fills a graphics window with red squares that get progressively darker from top to bottom and left to right. See below for sample snapshots of the final program as it runs Design specifications 1. 2. 3. 4. The "grid" of squares is 10x10, but you should make these variables that can be changed seamlessly at the top of your program. The graphics window should be titled "Color Grid", its width and height should be a function of the size of the squares contained in it. The color of the first square in the top-left corner should be (255, 0, 0). For each successive square, decrease the red value by 2. In order to "animate" the color grid, you will need to use a timer. To do this, import the time library at the top of your program. Then, when you want to pause the code, simply use time sleep (0.02). The 0.02 is the number of seconds your computer will wait before continuing to execute the program. Play around with this value and observe the behavior You should use a for loop for every column in the grid. So, your code will have 10 for loops, one right after the other At the end of your code, wait for the user to press a key using the getKex.) method. 5. 6
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started