Question
Writing the code in IDLE. Make sure the code is working. thank you so much

Create the following turtle pattern. Using the turtle and random modules, write a program that creates an output as the one s
. You have to make your turtle to change its heading to the right with an random angle between O and 45 degrees. Move your tu
Create the following turtle pattern. Using the turtle and random modules, write a program that creates an output as the one shown in the picture below. Consider the following: . Change the color of the window to "red" using wn.bgcolor property of the screen variable you create. . Your turtle variable has to have a pen color "white", you have to use the .pencolor property of your turtle variable. You have to make your turtle to change its heading to the right with an random angle
. You have to make your turtle to change its heading to the right with an random angle between O and 45 degrees. Move your turtle forward a random distance between O and 150 pixels. . Then move the turtle backward the same distance than above Repeat the last three steps 100 times
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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
import random

#creating a Screen variable
win=turtle.Screen()
#creating a Turtle variable
t=turtle.Turtle()
#setting red background for screen
win.bgcolor('red')
#setting a white color for pen color
t.pencolor('white')
#setting maximum drawing speed
t.speed(0)

#looping for 100 times
for i in range(100):
    #turning right a random angle between 0 and 45
   
t.right(random.randint(0,45))
    #generating a distance between 0 and 150
   
distance=random.randint(0,150)
    #moving forward distance spaces
   
t.forward(distance)
    # moving backward distance spaces
   
t.backward(distance)

#finish drawing
turtle.done()

#output

Python Turtle Graphics

Add a comment
Know the answer?
Add Answer to:
Writing the code in IDLE. Make sure the code is working. thank you so much Create the following turtle pattern. Using the turtle and random modules, write a program that creates an output as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • complete the code The instructions to a turtle can be encoded in a string. Complete Asn4_5...

    complete the code The instructions to a turtle can be encoded in a string. Complete Asn4_5 as follows: In main() the user will be prompted to enter instructions to a turtle as follows. The instructions will be entered in a loop that will end when the user enters quit or Quit at the first prompt. The first prompt will ask for a color. If the user enters quit or the user enters Quit the program will exit. The second prompt...

  • Complete the code The instructions to a turtle can be encoded in a string. Complete Asn4_5 as fo...

    complete the code The instructions to a turtle can be encoded in a string. Complete Asn4_5 as follows: In main() the user will be prompted to enter instructions to a turtle as follows. The instructions will be entered in a loop that will end when the user enters quit or Quit at the first prompt. The first prompt will ask for a color. If the user enters quit or the user enters Quit the program will exit. The second prompt...

  • I cannot run this code! Please explain and fix it for me import turtle import random...

    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...

  • Using Python. You will create two classes and then use the provided test program to make sure your program works This m...

    Using Python. You will create two classes and then use the provided test program to make sure your program works This means that your class and methods must match the names used in the test program You should break your class implementation into multiple files. You should have a car.py that defines the car class and a list.py that defines a link class and the linked list class. When all is working, you should zip up your complete project and...

  • Please help: For this project, you will create a shape drawing program using Turtle graphics. Your...

    Please help: For this project, you will create a shape drawing program using Turtle graphics. Your program will begin by asking the user how many points they would like to enter (# of vertices for the shape). Next, you will use a loop to input each X and Y coordinate and store these coordinates in lists. After inputting all of the coordinates, create a second loop that will draw and fill the shape using the coordinates that were entered. All...

  • Add another changeColor() method (i.e. you will now have 2 methods called "changeColor"). This one accepts...

    Add another changeColor() method (i.e. you will now have 2 methods called "changeColor"). This one accepts an int parameter and changes the color based on that int. The valid colors are "red", "yellow", "green", "blue", "magenta" and "black". In your code, map each color to an integer (e.g. in my code 3 means green.) If the number passed to the method is not valid, change the color to red. In the bounceTheBall() method, where you test for collisions with top...

  • Create a program to recreate the classic race between the hare and the tortoise. Each animal...

    Create a program to recreate the classic race between the hare and the tortoise. Each animal will move across the screen left to right over the course of 70 squares from 1 - 70 (each will have their own variable valued 1 - 70 and will print as an H or T) . Random numbers will determine the amount each animal will move forward or backward. You will write a program calls functions that uses pointers and pass by reference...

  • A random walk is a particular kind of probabilistic (pseudo-random) simulation that models certai...

    A random walk is a particular kind of probabilistic (pseudo-random) simulation that models certain statistical systems, such as Brownian motion of particles or molecules. Coin flipping is an example of a one-dimensional random walk--one dimensional because you only can go forward (when you flip heads) or backward (when you flip tails) along a straight line. Suppose you take a random walk of nsteps. How many steps away from your starting point would you expect to end up on average, if...

  • This is the code we have to edit, i know how to do everything except finding...

    This is the code we have to edit, i know how to do everything except finding if the x and y are in the space, please explain to me when you do the code. We are using addshape() api and more. public class Skeleton { public static void main(String[] args) { //================================ //== Setting up game window ====== SpaceGame myGame; //declaring the object form the class Scanner scan = new Scanner(System.in); System.out.println("What is the window name? "); //window title text...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT