fix this python program (error:NameError: name 'turtle' is not defined)
def Drawtriangularmotion():
import turtle
import random
index=0
size=[80,75,60]
color=['red','green','blue']
myTurtle=turtle.Turtle()
screen = turtle.Screen()
def draw_square():
global index
myTurtle.fillcolor(color[index])
myTurtle.begin_fill()
for _ in range(4):
myTurtle.left(90)
myTurtle.forward(size[index])
myTurtle.end_fill()
index+=1
def draw_triangle():
for _ in range(3):
draw_square()
myTurtle.penup()
myTurtle.forward(450)
myTurtle.left(120)
myTurtle.pendown()
def main():
draw_triangle()
screen.exitonclick()
main()
CODE:
import turtle
import random
index=0
size=[80,75,60]
color=['red','green','blue']
myTurtle=turtle.Turtle()
screen = turtle.Screen()
def draw_square():
global index
myTurtle.fillcolor(color[index])
myTurtle.begin_fill()
for _ in range(4):
myTurtle.left(90)
myTurtle.forward(size[index])
myTurtle.end_fill()
index+=1
def draw_triangle():
for _ in range(3):
draw_square()
myTurtle.penup()
myTurtle.forward(450)
myTurtle.left(120)
myTurtle.pendown()
def main():
draw_triangle()
screen.exitonclick()
main()
OUTPUT:

fix this python program (error:NameError: name 'turtle' is not defined) def Drawtriangularmotion(): import turtle ...
import random import turtle def isInScreen(win,turt): leftBound = -win.window_width() / 2 rightBound = win.window_width() / 2 topBound = win.window_height() / 2 bottomBound = -win.window_height() / 2 turtleX = turt.xcor() turtleY = turt.ycor() stillIn = True if turtleX > rightBound or turtleX < leftBound: stillIn = False if turtleY > topBound or turtleY < bottomBound: stillIn = False return stillIn def main(): wn = turtle.Screen() # Define your turtles here june = turtle.Turtle() june.shape('turtle') while isInScreen(wn,june): coin = random.randrange(0, 2) if...
I cannot run this code! Please explain and fix it for me import turtle import random # Approximate size of turtle objects in pixels BODY_SIZE = 80 # Half if the body size for collision detection with the edge of the screen HALF_BODY_SIZE = BODY_SIZE / 2 # if enemies get this close to friend there is collision COLLISION_DISTANCE = 5 # The window size SIZE = 500 # inner boundary within window for reversing the direction of enemies LOWER_BOUND...
Answer must be in Python 3
Answer:
import turtle
def trifecta(size,angle,num):
for i in range(num):
tri(t,size)
t.right(angle)
t = turtle.Turtle()
s = turtle.Screen()
trifecta(100,25,5)
Question 11 Part b (10 points) Write a function named trifecta() that takes three parameters: 1. size 2. angle 3. num trifecta() should call tri() repeatedly so as to draw num triangles, each with sides of length size. Each triangle should be oriented angle degrees clockwise from the preceding triangle. trifecta() should create a turtle and...
How to make turtle in python, make the icon a turtle icon that
gets gradually smaller as it goes up the screen.
import turtle
import math
def main():
w = int(input('Width: '))
h = int(input('Height: '))
turtle.setup(w,h)
# Moving turtle
mTurtle = turtle.Turtle()
# function call
#movingTurtle(mTurtle,window)
main()
Part D: (movingTurtle) Give a set of instruction that sets the turtle to an actual turtle shape, and moves it form the bottom of the screen towards the top, getting smaller as...
Hi, can you help me add these requirements in my Turtle python program. The program is supposed to run an Olympics skating game. The program is below the requirements. Thanks Requirements -Your race will be random generated so each time there is a possibility that a different winner. -Have a countdown of “READY” “SET” “GO” appear on the screen and then the turtles take off. -Have the program tell the winner[s]. -Award Medals. -User may guess who will win. -Allow...
Here is a Python program. import turtle class Box: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height def show(self): turtle.up() turtle.goto(x, y) turtle.down() for _ in range(2): turtle.forward(width) turtle.right(90) turtle.forward(height) turtle.right(90) bigbox = Box(-100, -150, 200, 300) bigbox.show() turtle.done() If you run the above program, it will produce an error. What is the keyword that has...
I need help with this code, I have it started here
import sys
import turtle
menu = "Press 1 for Flower"
UserChoice = input(menu)
#function to draw squares
def draw_square(square):
for i in range(0,2):
square.forward(100)
square.right(70)
square.forward(100)
square.right(110)
#function to draw flower
def draw_flower(petalNumber):
window = turtle.Screen()
window.bgcolor("yellow")
pen = turtle.Turtle()
pen.shape("triangle")
pen.color("red")
for number in range(0,petalNumber):
draw_square(pen)
pen.right(360/petalNumber)
for i in range(0,4):
pen.circle(20)
pen.right(90)
pen.right(90)
pen.forward(300)
pen.right(90)
draw_square(pen)
pen.left(180)
draw_square(pen)
pen.left(270)
pen.forward(200)
window.exitonclick()
#function for original art...
Using python
Here is the code
import turtle
def draw_triangle(vertex, length, k):
'''
Draw a triangle at depth k given the bottom vertex.
vertex: a tuple (x,y) that gives the coordinates of the bottom
vertex.
When k=0, vertex is the left bottom vertex for the outside
triangle.
length: the length of the original outside triangle (the
biggest one).
k: the depth of the input triangle.
As k increases by 1, the triangles shrink to a smaller
size.
When k=0, the...
Hi I need assistance getting rid of the ugly line and this is
python 3.7
Please explain how you fixed this !
File Edit Format View Help 4.1.14 in the profitPlot function in the text, fix the problem raised by reflection 4.15 Reflection: when you run this plotting program, you wil1 notice an ugly line from the origin to the first point of the plot. How can you fix this? import turtle def profitPlot(tortoise, maxPrice): for price in range(1,2 maxPrice+1):...
Must be done in python. This will be connected to other turtle
assignments. Might need a sleep at end.
Swimming in a Pond In this function, you will draw a small pond and have the turtle first take a nice walk around it and then jump in. The pond will need to be drawn in the upper left quandrant of your screen. This function needs to do the following: Contain two parameters to denote the color of the path (pen...