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 Java application that inputs an unknown number of employees and determines and displays the...
Write a Java application that inputs an unknown number of employees and determines and displays the gross pay for each employ. The company pays straight time for the first 40 hours worked by each employee (hours times rate), and straight time plus time-and-a-half for all hours worked in excess of 40 hours. Input the number of hours worked and hourly rate for each of the employees, then determine and display the employee’s gross pay. At the end of the program,...
Write an application named DisplayMultiplicationTable that displays a table of the products of every combination of...
Write an application named DisplayMultiplicationTable that displays a table of the products of every combination of two integers from 1 through 10 Beginning Code. Please answer in C# using static System.Console; class DisplayMultiplicationTable { static void Main() { // Write your main here. } } }
Write an HTML/Javascript canvas program that displays a black dot in the center after the user...
Write an HTML/Javascript canvas program that displays a black dot in the center after the user presses the 's' button on the keyboard. Hint: Canvas size should be 500x500 and the black dot should only appear after pressing 's'.
Java Write a JavaFX application that displays a button and a number. Every time the button...
Java Write a JavaFX application that displays a button and a number. Every time the button is pushed, change the number to a random value between 1 and 100. Thank you and can you show a picture of the result as well
Java Math Tutor: Write a program that displays a menu as shown in the sample run....
Java Math Tutor: Write a program that displays a menu as shown in the sample run. You can enter 1, 2, 3, or 4 for choosing an addition, subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter 5 to exit the system. Each test generates two random single-digit numbers to form a question for addition, subtraction, multiplication, or division. For a subtraction such as number1 – number2, number1...
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 a JavaFX application that draws 5 squares. Use a random number generator to generate random...
Write a JavaFX application that draws 5 squares. Use a random number generator to generate random values for the size, x, and y. Make the size between 100 and 200, x between 0 and 600, y between 0 and 400. You can pick any color, but you must use different colors for the 5 squares. Set your window to 600 by 400.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT