subject

# starter. py '' Draw random "art" in a Mondrian style '''
import turtle
import random
# Height and width of the turtle window
WIDTH = 1024
HEIGHT = 768
def drawSquare(x, y, w, h, color, tur):
'''
Draw a rectangle with the Lower Right corder at (x, y)
The width of the rectangle is w and its height is h
The fill color for the rectangle is specified by color
'''
tur. up()
# First Corner
tur. goto(x, y)
tur. down()
tur. fillcolor(color)
tur. begin_fill()
# Second Corner
tur. goto(x+w, y)
# Third Corner
tur. goto(x+w, y+h)
# Fourth Corner
tur. goto(x, y+h)
# Back to First Corner
tur. goto(x, y)
tur. end_fill()
tur. up()
def randomColor():
'''
Select a color randomly
Return a random color as described in the assignment.
This color is just a string with the name of the color
''
'# You must write this function
def split_horiz(x, y, w, h, tur):
'''
Split horizontally - So one rectangle is beside the other.
Make a recursive call to the "art" function for each smaller rectangle.
++ +++
| | | | |
| | Becomes | | |
++ +++
'''
# You must write this function
def split_vert(x, y, w, h, tur):
'''
Split Vertically - So one rectangle is above the other
Make a recursive call to the "art" function for each smaller rectangle.
+---+ +---+
| | | |
| | Becomes | |
| | +---+
| | | |
+---+ +---+
'''
# You must write this function
def split_both(x, y, w, h, tur):
'''
Split both vertically and horizontally
Make a recursive call to the "art" function for each smaller rectangle.
++ +++
| | | | |
| | Becomes | | |
| | | | |
| | +++
| | | | |
++ +++
'''
# You must write this function
def doSplit(dim):
'''
Decide at random whether or not to split
'''
# You can call this function from the "art" function
# when deciding randomally whether or not to do a split.
# Putting this logic in a function makes the "art" function
# easier to think about.
# This function should return True or False
def art(x, y, w, h, tur):
'''
Use recursion to draw "art" in a Mondrian style
Input is a rectangle with bottom left corner at (x, y)
and with width w and height h.
'''
# This is where you decide whether or not to split a rectangle.
# To do the split, you'll call one of the three split functions above.
# They will in turn make recursive calls back to this function.
def makeTurtle():
'''
Set up the turtle
'''
turtle. setworldcoordinates(-2, -2, WIDTH+18, HEIGHT+8) # Trial and error
turtle. setup()
ourWindow = turtle. Screen()
ourWindow. title('Recursive Art')
ourWindow. tracer(0) # Comment this line to turn off animation
tur = turtle. Turtle()
tur. hideturtle()
tur. speed('fastest')
tur. width(3)
return tur
def main():
# You can uncomment the following line so you program will always behave the same
# random. seed(1985)
# Create the turtle
tur = makeTurtle()
# Draw the art
art(0, 0, WIDTH, HEIGHT, tur)
turtle. done()
main()

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:40
When running anti-virus software , what could be a reason where recipitent is not guaranteed that data being streamed will not get interrupted?
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 22.06.2019 19:50
Write a car class having two private member variables called tank and speed. write public methods called pumpgas and gofast. the method pumpgas gets an integer for gas that must be pumped. that value needs to be added to tank (no more than 20 gallons). it must return the amount of gas that is purchased ($4 per gallon). the method gofast should increase the speed by 5 each time it is called.write a constructor for the above class that initialized both variables to zero.write a tostring to display both the tank and speed when the car is printed.modify the car class to implement the interface comparable and an interface called carinter having the public methods in carinter.write the main program to create an array of size 5 of type car. create 5 car objects having each location of the array to refer to one of the cars. test the pumpgas, gofast, equals method on the array items. write an enhanced loop to print all the car values (using a tostring written last time).write a generic method to find the minimum of four items. pass int, double, char, string and car objects to test this method.
Answers: 1
question
Computers and Technology, 23.06.2019 04:20
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy.a. a fire occurs on the premises, and the building isbadly damaged.b. a burglar steals some money and securities from anunlocked safe.c. a business computer is damaged by vandals whobreak into the shop after business hours.d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm.til
Answers: 2
You know the right answer?
# starter. py '' Draw random "art" in a Mondrian style '''
import turtle
import random<...
Questions
question
Mathematics, 22.08.2019 05:30
Questions on the website: 13722367