1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marshall27 [118]
3 years ago
5

How to create a checkerboard on Python turtle?

Computers and Technology
1 answer:
mafiozo [28]3 years ago
6 0

Answer:

here is my crude attempt:

import turtle

t = turtle.Turtle()

t.speed(0)

colors = ["black", "yellow"]

SQUARES = 8

SQUARESIZE = 20

def rectangle(color, s):

 t.begin_fill()

 t.pendown()

 t.color(color)

 for i in range(4):

   t.forward(s)

   t.right(90)

 t.end_fill()

 t.penup()

for row in range(SQUARES):

 for col in range(SQUARES):

   t.setpos(row*SQUARESIZE, col*SQUARESIZE)

   rectangle(colors[(row+col)%2], SQUARESIZE)

You might be interested in
Given public class Fishing { byte b1 = 4; int i1 = 123456; long L1 = (long) i1; //Line A short s2 = (short) i1; //Line B byte b2
Aleksandr [31]

Answer:

Line E.

Explanation:

The  given program is as follows:

public class Fishing {

   byte b1 = 4; int i1 = 123456; long L1 = (long) i1;   //Line A

   short s2 = (short) i1;     //Line B

   byte b2 = (byte) i1;     //Line C

   int i2 = (int)123.456;    //Line D

   byte b3 = b1 + 7;     //Line E

   }

In the above code Line E will not compile and give following compilation error:

error: incompatible types: possible lossy conversion from int to byte

This error is coming because in Java b1 + 7 will be interpreted as int variable expression. Therefore in order to make code of Line E work the expression should be type casted as byte.  

The correct code will be as follows:

public class Fishing {

   byte b1 = 4; int i1 = 123456; long L1 = (long) i1;   //Line A

   short s2 = (short) i1;     //Line B

   byte b2 = (byte) i1;     //Line C

   int i2 = (int)123.456;    //Line D

   byte b3 = (byte)(b1 + 7);     //Line E

   }

5 0
2 years ago
Write a computer program that determines how many grades are between 0 and 19.
True [87]

Answer:

public class nnn {

   public static void main(String[] args) {

       int [] examScores = {31, 70, 92, 5, 47, 88, 81, 73, 51, 76, 80, 90, 55, 23, 43,98,36,87,22,61, 19,69,26,82,89,99, 71,59,49,64};

       int zeroTo19 = 0;

       int nineteenTo39 = 0;

       int fortyTo59 = 0;

       int sixtyTo79 = 0;

       int eightyTo100 = 0;

       for(int i =0; i<examScores.length; i++){

           if(examScores[i]<=19){

               zeroTo19++;

           }

           else if(examScores[i]>19&&examScores[i]<=39){

               nineteenTo39++;

           }

           else if(examScores[i]>39&&examScores[i]<=59){

               fortyTo59++;

           }

           else if(examScores[i]>59&&examScores[i]<=79){

               sixtyTo79++;

           }

           else {

               eightyTo100++;

           }

       }

       System.out.println("0 - 19 is "+zeroTo19);

       System.out.println("20 - 39 is "+nineteenTo39);

       System.out.println("40 - 59 is "+fortyTo59);

       System.out.println("60 - 79 is "+sixtyTo79);

       System.out.println("80 - 100 is "+eightyTo100);

   }

}

Explanation:

  • This has been solved with Java
  • Create an array of the exam scores
  • Create new variables for each of the score range
  • Use multiple if statements as u loop through the array to determine the range of scores
  • Finally outside the loop print them variables out
7 0
2 years ago
Employees often attend trainings and read policies. They endure these, but do not internalize them. What should be your first st
Vlada [557]

Answer:

I would say b but if I'm wrong take the point back

7 0
1 year ago
In order to view the permissions assigned to each type of user for all the files located in a directory, which of the following
Rufina [12.5K]

The correct answer is B: ls -l.

Further Explanation:

In Linux there is a specific command needed to look at the files in a directory. In addition to using the command ls -l, you will need to use < > after the command and insert the name of the file that is being looked for. For example: ls -l <root root 2356 0600 Oct 22 lanyard>.

Each word and character has their own meaning and access information stored in the database. This will also show the users accesses permission to see the file and if needed to write over the file.

Learn more about computer commands at brainly.com/question/13338803

#LearnwithBrainly

5 0
2 years ago
All users at your site are using the Bash shell. You want to set a variable that will apply to every user and always have the sa
podryga [215]

Explanation:

I assume you are on a single host.

To modify the .bashrc for all NEW users, you can edit/modify (with su privilege) the file

/etc/skel/.bashrc

save the file before creating new users.

Be sure to know what you're doing, and test the file before you use it host-wide.

For existing users, you can have them do the modifications/additions individually in case they have already modified their own version.

4 0
3 years ago
Other questions:
  • Write a function DrivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar
    12·1 answer
  • What is the downside of wider channel bandwidth?
    15·1 answer
  • You have three users who travel to four branch offices often and need to log on to the RODCs at these offices. The branch office
    12·1 answer
  • What set operator would you use if you wanted to see all of the Customers and the Employees including any records that may appea
    14·1 answer
  • Expain the application areas of ICT in education sector and E-commerce​
    12·1 answer
  • Activity
    7·1 answer
  • Which graphic file format is used for commercial purposes.
    10·1 answer
  • How many parameters can we use in each function?
    15·1 answer
  • ____ is a technology that exists inside another device
    9·2 answers
  • What number will this code return?<br> Math.max(7, 5, 9);
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!