Question

In: Computer Science

write a graphical application that displays a checkerboard with 25 squares.(black and white only and run...

write a graphical application that displays a checkerboard with 25 squares.(black and white only and run from pycharm.

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

#code


import turtle

#creating a turtle, setting max speed
t=turtle.Turtle()
t.speed(0)

#number of columns, rows
cols=5
rows=5
#size of each square
size=60

#starting position
x=-150
y=150
#pen up
t.up()
#initial color - black
color='black'
#looping through each row and column
for i in range(rows):
    for j in range(cols):
        #moving turtle to x,y
       
t.goto(x, y)
        #using current color as fill color
       
t.fillcolor(color)
        #start to fill
       
t.begin_fill()
        #filling a rectangular path
       
t.forward(size)
        t.right(90)
        t.forward(size)
        t.right(90)
        t.forward(size)
        t.right(90)
        t.forward(size)
        t.right(90)
        #end of fill
       
t.end_fill()
        #moving x size spaces forward
       
x+=size
        #swapping colors between black and white
       
if color=='black':
            color='white'
       
else:
            color='black'
   
#resetting x to starting position
   
x=-150
    #updating y size spaces down
   
y-=size

#hiding turtle and finishing drawing
t.ht()
turtle.done()

#output



Related Solutions

Suppose there are 10 black quarterbacks and 25 white quarterbacks in the NFL draft, and that...
Suppose there are 10 black quarterbacks and 25 white quarterbacks in the NFL draft, and that all quarterbacks are of equal ability; specifically, all quarterbacks in the draft have a 20% chance of succeeding in the NFL. However, suppose NFL coaches have an incorrect view that white quarterbacks are more likely to succeed than black quarterbacks. As a result, they decide to cut ½ of all black quarterbacks that were drafted and 1/5 of all white quarterbacks that were drafted....
Write a JavaFX application that displays a Label containing the opening sentence or two from your...
Write a JavaFX application that displays a Label containing the opening sentence or two from your favorite book. Save the project as FXBookQuote1a. Add a button to the frame in the FXBookQuote program. When the user clicks the button, display the title of the book that contains the quote in a second label. Save the project as FXBookQuote1b // FXBookQuote1a.java import javafx.application.Application; import static javafx.application.Application.launch; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.Pane; import javafx.scene.text.Font; import javafx.stage.Stage; public class FXBookQuote1a...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
Write an assembly program that lets the user to input only the word MASM and displays...
Write an assembly program that lets the user to input only the word MASM and displays invalid input for any other user inputs.
Write an application named OddNums that displays all the odd numbers from 1 through 99. All...
Write an application named OddNums that displays all the odd numbers from 1 through 99. All ODD numbers should show all together(Should not need to scroll down), do it in 10 rows. FOR C#
25:Any white space beyond what it takes to make words clearly readable is wasteful, and only...
25:Any white space beyond what it takes to make words clearly readable is wasteful, and only serves to unnecessarily lengthen the document. A:true B:false 26:Repeating information within a document should be avoided, as it doesn't add anything to the message and it will lower reader attention levels. A:true B:false 27:What is the maximum number of items you want in an unbroken list? a. 10 b. 8 c. 7 d. 6 e. 9 28:What should you do if you have a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT