Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone show me how to do this? This is for Python l - I am using PyCham 3.6

ID: 3886384 • Letter: C

Question

Can someone show me how to do this? This is for Python l - I am using PyCham 3.6 version and having difficulty.

Type in following :

from turtle import*

pencolor('red')

goto (100,0)

a. Draw a red line

b. Draw 10 black vertical and 10 black horizontal lines in a regular grid. How would you repeatedly do this task? Speed up turtle by setting its speed to 0 and do it by calling the function speed with argument 0: speed(0).

c. Draw green rectilinear square using forward() and left().

e. Draw a filled green rectilinear square using goto().

Explanation / Answer

These are executed and working skcripts have a look at each one carefully

Run each script indiviualy to see the output

#(a)Drawing the line of color red

import turtle

fred = turtle.Pen() #shape of drawer
fred.color("red") #color of line
fred.forward(100) #draqing forward line

#(b)Drwa a green rectiliner square

import turtle

Rect= turtle.Pen()
Rect.forward(100) #draqing forward line
Rect.right(90) #draqing right side line
Rect.forward(100) #draqing forward line
Rect.right(90) #draqing right side line
Rect.forward(100) #draqing forward line
Rect.right(90) #draqing right side line
Rect.forward(100) #draqing forward line
Rect.right(90) #draqing right side line

#(D)Draw Rectiliner with green
#Goto is not suported in python we can do it by lable and decrator fucntion if you want comment

import turtle

fill_rect = turtle.Pen()

fill_rect.color("red","green") //1st parameter pen color ,2 nd background color
fill_rect.begin_fill()
fill_rect.forward(100)
fill_rect.right(90)
fill_rect.forward(100)
fill_rect.right(90)
fill_rect.forward(100)
fill_rect.right(90)
fill_rect.forward(100)
fill_rect.right(90)
fill_rect.end_fill()

#######

###########(B) Grid

import turtle
def drawGrid():
turtle.penup()
turtle.goto(-300, 250)
turtle.pendown()
turtle.forward(300)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(300)

def drawColumns():
for i in range(4):
turtle.right(90)
turtle.forward(37.5)
turtle.right(90)
turtle.forward(300)
turtle.left(90)
turtle.forward(37.5)
turtle.left(90)
turtle.forward(300)

def drawRows():
turtle.left(180)
rows = 0
while rows <= 3:
rows += 1
turtle.forward(37.5)
turtle.right(90)
turtle.forward(300)
turtle.left(90)
turtle.forward(37.5)
turtle.left(90)
turtle.forward(300)
turtle.right(90)

drawGrid() # Draw grids

drawColumns() #Draw the colums

drawRows() # Draw rows