Question

In: Computer Science

I need to draw my first name using Turtle. I am struggling with "P" and "A"...

I need to draw my first name using Turtle. I am struggling with "P" and "A" this is what I have

import turtle

turtle.setup(800, 700)

window = turtle.Screen()

window.reset()

window.bgcolor('cornsilk')

t = turtle.Turtle()

t.color('blue')

t.pencolor('red')

t.turtlesize(6)

t.speed(2)

t.up()

t.setposition(-50, 0)

t.pendown()#Drawing letter T

t.forward(40)

t.back(20)

t.right(90)

t.forward(50) t.left(90)

t.penup() t.forward(70)

t.left(90) t.forward(25)

t.pendown()

t.circle(25)# Drawing letter O

t.penup()

t.left(180)

t.forward(25)

t.left(90)

t.forward(10)

t.pendown()#Drawing letter N

t.left(90)

t.forward(50)

t.right(150)

t.forward(60)

t.left(150)

t.forward(53)

t.back(53)

t.right(90)

turtle.done()

Solutions

Expert Solution

code:

import turtle

turtle.setup(800, 700)
window = turtle.Screen()
window.reset()
window.bgcolor('cornsilk')
t = turtle.Turtle()
t.color('blue')
t.pencolor('red')
t.turtlesize(6)
t.speed(2)

def drawA(width, height):
    """
    t will draw the letter A with a given width and height,
    with the current location being the lower left corner of the A.
    """

    # figure out where we are

    startX = t.xcor()
    startY = t.ycor()

    # figure out the other points using only what we know,
    # which is width, height, startX and startY
    
    topAX = startX + (width/2)
    topAY = startY + height

    bottomRightX = startX + width
    bottomRightY = startY
    
    barLeftX = startX + width/4
    barLeftY = startY + height/2

    barRightX = startX + (width/4) + (width/2)
    barRightY = startY + height/2
    
    # draw left hand side of the A    
    t.goto(topAX,topAY)

    # draw the right side of the A

    t.goto(bottomRightX, bottomRightY)

    # draw bar across the middle
    
    t.up()
    t.goto(barLeftX,barLeftY)
    t.down()
    t.goto(barRightX,barRightY)

    # leave turtle at lower right hand corner of letter
    
    t.up()
    t.goto(bottomRightX,bottomRightY)
    t.down()

def drawT(width,height):
   '''
   draw a T
   assume turtle facing east (0), and leave it facing east
   assume pen is down
   no assumptions about position.
   '''
   t.forward (width)
   t.backward (width/2)
   t.right (90)
   t.forward (height)
   t.left(90)

def drawO(width,height):
    """
    Draw the digit zero.  Assumes aTurtle starts pointing right,
    pen down
    at lower left of a rectantgle, with given width and height.

    Leave the turtle pointing right at the lower right of that
    same rectangle when done, with pen still down.
    """
    # Go counter-clockwise around the box
    t.forward(width)
    t.left(90)
    t.forward(height)
    t.left(90)
    t.forward(width)
    t.left(90)
    t.forward(height)
    t.left(90)
    # Now move over to lower left corner
    t.up()
    t.forward(width) 
    t.down()
def drawN():
    t.left(90)
    t.forward(100)
    t.right(150)
    t.forward(116)
    t.left(150)
    t.forward(100)
    t.up()
    t.right(180)
    t.forward(100)
    t.left(90)

def drawP():
    t.left(90)
    t.forward(100)
    t.right(90)
    t.circle(-30, 180, 50)

t.up()
t.setposition(-300, 0)
t.down()

drawT(50,100)

t.up()
t.forward(50)
t.down()

drawO(50, 100)
t.up()
t.forward(50)
t.down()

drawA(50, 100)

t.up()
t.forward(50)
t.down()

drawN()

t.up()
t.forward(50)
t.down()
drawP()

turtle.done()

output:


Related Solutions

Hi there I need to write an ethic issue in technology but I am struggling to...
Hi there I need to write an ethic issue in technology but I am struggling to choose a topic. I am asking about the possibility of "Ethical issues" topics that is tread common in technology. Would anyone can give me some options to choose from. Thank you.
I am struggling with the following accounting problem. I need to calculate the following breakeven point...
I am struggling with the following accounting problem. I need to calculate the following breakeven point in dollars. Sales 240 units or $1,200,000 ($5.00 per unit), cost of goods sold 784,000, gross profit 416,000, operating expense are 280,000 for selling and 156,000 for administrative expenses. The analysis indicates 75% of COGS are variable, 42% of selling are variable and 40% of administrative are variable. Those numbers are $588,000, 117,600 and 62,400. The fixed cost are 25% of COGS, 58% of...
I am struggling with easy problem. Can you pls check my work ? The patient is...
I am struggling with easy problem. Can you pls check my work ? The patient is to receive 500 mL of D5W over 6 hours . What is the drip rate per minute if the tubing provides 12 gtts per mL? Gtt/min 12gtt/ml x 500/360 min =6000/360=118 gtt/min A patient who weighs 74 pounds has an order for Advil (ibuprofen) 3.5 mg/kg every 6 hours. How many mg will you give in a single dose? 3,5MG /KG X33.6KG =118 MG...
Use Turtle graphics to draw your first name or your nickname if over 6 letters.           Just...
Use Turtle graphics to draw your first name or your nickname if over 6 letters.           Just initials of your first & last name is OK if you add another feature such as color. My initials are J.S but I don't know how to color them. Here is my code: Python program to print nick name if a name is greater than 6 character or initials if the color if given """ import turtle as T fName, lName = input('Enter name:...
I am stuck in Austin with a flat tire, and I need to get to my...
I am stuck in Austin with a flat tire, and I need to get to my class in Houston within 2 hours. The drive is 180 miles long, but I want to be careful of the Austin cops. I do not usually get caught speeding unless I am seen accelerating too fast, so I do not want to accelerate at a rate of more than 120 mi?/?h2. Just to be careful, I?m going to take exactly 2 hours to make...
Hello, I am struggling to understand some of my accounting homework. Question 01 ) Tulsa Company...
Hello, I am struggling to understand some of my accounting homework. Question 01 ) Tulsa Company is considering investing in new bottling equipment and has two options: Option A has a lower initial cost but would require a significant expenditure to rebuild the machine after four years; Option B has higher maintenance costs, but also has a higher salvage value at the end of its useful life. Tulsa’s cost of capital is 11 percent. The following estimates of the cash...
Hi, I am struggling to understand this worksheet my professor gave us for practice. Could someone...
Hi, I am struggling to understand this worksheet my professor gave us for practice. Could someone make any sense of this? The scenario: Sodium is found largely in the extracellular compartment with concentrations between 130-145 mM with intracellular sodium concentrations between 3.5-5mM. This chemical difference gives sodium a large concentration gradient, which when permitted (by opening of a channel or through facilitated transport) will move down its concentration gradient to enter the cell. Sodium also has a favorable electrical gradient;...
My name is Donna. I am a college student studying to be an English teacher. I...
My name is Donna. I am a college student studying to be an English teacher. I dislike inflation, my degree is costing me more than i had anticipated. Good thing that I am a senior, tuition when I started three years ago was 20% less. Maybe I should get my masters but that would put me unto more debt. Why do we have so much inflation? I work part time as a server and have a low fixed rate loan...
My name is Charles, but my friends and family call me Chuck. I am the fifth...
My name is Charles, but my friends and family call me Chuck. I am the fifth child in a family of 7, three older sisters and an older brother before me, and a sister one a year younger and a brother 5 years younger than her. Due to the age difference between my sister and my little brother, jokes were told in family gatherings referring to my little brother as an “accident” or as “Ramses” making reference to a popular...
using java program I need only the tracing in detail, using my name "Nada Hamdan" Part-A:...
using java program I need only the tracing in detail, using my name "Nada Hamdan" Part-A: Consider first ten letters of your name and for each letter encode with an integer number. For example: If “Ahmed Naser” are the first ten letters from your name, then the array of integers will be {0, 7, 12, 4, 3,13,0,18,4,17}. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT