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

with python, create a fake logo for a company using turtle graphics
with python, create a fake logo for a company using turtle graphics
Your (turtle) program in python must include: Create four Red turtles and four Blue turtles using...
Your (turtle) program in python must include: Create four Red turtles and four Blue turtles using one or more lists. • Start each of the Red turtles at a different random location on the left side of the screen within the range of the square formed by (-100, 100) and (0, -100) and each of the Blue turtles at a random location on the right side of the screen within the range of the square formed by (0, 100) and...
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...
Using Python, create a program that will act as a number convertor. This program will convert...
Using Python, create a program that will act as a number convertor. This program will convert an input decimal integer into binary and hexadecimal formats. a) Define a main function named numberconvertor(). Inside the main function, write all the logic of your code. [5% marks] b) Looping indefinitely (Hint: use infinite while loop), the program should give the user the 3 options given below and allow the user to select one among them. [15% marks] 1. converting a decimal number...
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...
How to do this in Python (using Lists): Create a python program that allows a user...
How to do this in Python (using Lists): Create a python program that allows a user to display, sort and update as needed a List of U.S States containing the State Capital and State Bird. You will need to embed the State data into your Python code. The user interface will allow the user to perform the following functions: 1. Display all U.S. States in Alphabetical order along with Capital and Bird 2. Search for a specific state and display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT