Question

In: Computer Science

What would the Python code be to create the following working program using turtle: -Make 4...

What would the Python code be to create the following working program using turtle:

-Make 4 turtles that are YELLOW, and 4 turtles that are GREEN. Create these turtles using one or more lists.

-Make the yellow turtles start at a different randomized location somewhere on the left side of the screen within the range of (-100,100) and (0, -100)

-Make the green turtles start at a different randomized location somewhere on the right side of the screen within the range of (0,100) and (100, -100)

-Both the yellow and green turtles should be moving randomly.

-Create a boundary for the turtle game using a circle with a 500 unit radius using an invisible turtle- i.e.: it does not count as one of the turtles on either separately colored team.

-If a turtle hits the boarder, the turtle should have it's color changed to the color red and should teleport back to the center of the screen at (0,0) and continue moving with random movements.

-Every turtle should have a speed of 1.5

-All of the turtles should continue randomly moving and preforming the code above UNTIL 1500 time units have gone by.

Solutions

Expert Solution

Answer-

-Make 4 turtles that are YELLOW, and 4 turtles that are GREEN. Create these turtles using one or more lists.

Firstly you have to use the color() method of turtle module for changing color of turtle.

Now use color() method and take color name as argument and then write the whole code

import turtle

#create first turtle

my_turtle1 = turtle. Turtle()

my_turtle1.shape("turtle")

my_turtle1.color('yellow') #specify turtle color

(write this three more times)

#create second turtle

my_turtle2 = turtle. Turtle()

my_turtle2.shape("turtle")

my_turtle2.color('green') #specify turtle color

(write 3 more times)

turtle.done

-Make the yellow turtles start at a different randomized location somewhere on the left side of the screen within the range of (-100,100) and (0, -100)

import turtle

#create first turtle

my_turtle1 = turtle. Turtle

my_turtle1.setposition(-100,100)

my_turtle1.shape("turtle")

my_turtle1.color('yellow')

my_turtle1.left(150)

#create second turtle

my_turtle2 = turtle. Turtle()

my_turtle2.setposition(0, -100)

my_turtle2.shape("turtle")

my_turtle2.color("yellow")

my_turtle2.left(150)

turtle.done()

-Make the green turtles start at a different randomized location somewhere on the right side of the screen within the range of (0,100) and (100, -100)

import turtle

#create first turtle

my_turtle1 = turtle. Turtle

my_turtle1.setposition(0,100)

my_turtle1.shape("turtle")

my_turtle1.color('green')

my_turtle1.right(150)

#create second turtle

my_turtle2 = turtle. Turtle()

my_turtle2.setposition(100, -100)

my_turtle2.shape("turtle")

my_turtle2.color("green")

my_turtle2.right(150)

turtle.done()


-Both the yellow and green turtles should be moving randomly.

import turtle

import random

wn = turtle. Screen()

t = turtle. Turtle()

t.color("yellow")

for i in range (60)

t.pensize(random.randint(5,15))

t.goto(random.randint(-200,200), random.randint(-100,100))

if i = = 30:

t.color("green")

wn.mainloop()

-Create a boundary for the turtle game using a circle with a 500 unit radius using an invisible turtle- i.e.: it does not count as one of the turtles on either separately colored team.

import turtle

my_turtle = turtle. Turtle()

my_turtle.circle(500)

my_turtle.hideturtle() #hide the turtle

turtle.done()

-Every turtle should have a speed of 1.5

import turtle

turtle.speed(1.5)



Related Solutions

Using Python code create a program only with beginners code. You are taking online reservations at...
Using Python code create a program only with beginners code. You are taking online reservations at the The inn Ask for your client’s name and save in a variable Ask how many nights your client will be staying and save in a variable Room rental is $145 per night Sales tax is 8.5% Habitation tax is $5 per night (not subject to sales tax) Print out: Client’s name Room rate per night Number of nights Room cost (room rate *...
In python Using the example code from the HangMan program in our textbook, create a Word...
In python Using the example code from the HangMan program in our textbook, create a Word Guessing Game of your choice. Design a guessing game of your own creation. Choose a theme and build your words around that theme. Keep it simple. Note: I would highly recommend closely reviewing the HangMan code and program from Chapter 10 before starting work on this project. You can run the program via my REPL (Links to an external site.). Using python Similar to...
In python make a simple code. You are writing a code for a program that converts...
In python make a simple code. You are writing a code for a program that converts Celsius and Fahrenheit degrees together. The program should first ask the user in which unit they are entering the temperature degree (c or C for Celcius, and f or F for Fahrenheit). Then it should ask for the temperature and call the proper function to do the conversion and display the result in another unit. It should display the result with a proper message....
The coding for this program to run as described on Python: Your (turtle) program must include:...
The coding for this program to run as described on Python: Your (turtle) program must include: include import turtle on a line after the comments so you can use the various Turtle-related objects and methods. Create a turtle named after your favorite ice cream flavor. Make sure the name has no punctuation and consists only of letters, numbers and the underscore character. Write your python program so your turtle is constantly moving and can be turned left and right using...
Complete the following in syntactically correct Python code. Write a program, using a for loop, that...
Complete the following in syntactically correct Python code. Write a program, using a for loop, that calculates the amount of money a person would earn over a period of time if his or her salary is 1 penny for the first day, 2 pennies for the second day, 4 pennies for the third day, and continues to double each day. 1.      The program should ask the user for the number of days the employee worked. 2.      Display a table showing the salary...
Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
Making a program in Python with the following code types. I'm very confused and would love...
Making a program in Python with the following code types. I'm very confused and would love the actual code that creates this prompt and a brief explanation. Thanks! A comment on the top line of your program containing your name. A comment on the second line containing your section number. A comment on the third line containing the date. A comment on the fourth line containing your email address. A comment with the lab number and purpose of this lab....
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Need to make Java code as following: Create a dice playing threading program to do the...
Need to make Java code as following: Create a dice playing threading program to do the following: 1. Start a thread for a process to simulate a computer rolling a die 1000 times. 2. Start another thread for a process to simulate a user rolling a die 1000 times. 3. Keep track of rolls for user and computer in an array(s). 4. Display on screen when the computer thread starts, the rolls, and when the computer thread ends. 5. Display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT