Add a method to the Turtle class to draw a rectangle given a width and height.

Note: New method at bottom

```
class MyTurtle(Turtle):

#Assumes the turtle starts looking straight up
def drawTri(self, size=60):
self.turn(30)
for i in range(3):
self.forward(size)
self.turn(120)

#Assumes the turtle starts looking straight up
def drawRect(self, width=100, height = 100):
self.turnRight()
self.forward(width)
self.turnRight()
self.forward(height)
self.turnRight()
self.forward(width)
self.turnRight()
self.forward(height)
```

Computer Science & Information Technology

You might also like to view...

Sniffers look only at the traffic passing through the network interface adapter on the machine where the application is resident.?

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hun- dredth and the number rounded to the nearest thousandth.

Function floor can be used to round a number to a specific decimal place. The statement y = floor( x * 10 + .5 ) / 10; rounds x to the tenths position (the first position to the right of the decimal point). The statement y = floor( x * 100 + .5 ) / 100; rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines four functions to round a number x in various ways: a) roundToInteger( number ) b) roundToTenths( number ) c) roundToHundredths( number ) d) roundToThousandths( number )

Computer Science & Information Technology