Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this code, I need it updated to python 3.6 import cs1graphics #from time import sleep import cs1graphics import math print('Assignment 6.1')

I need help with this code, I need it updated to python 3.6

import cs1graphics #from time import sleep import cs1graphics import math

print('Assignment 6.1') print('Cassandra Sutton') print('04/5/2018')

print('Problem 1') class Rectangle: def __init__(self): self.x = 0 self.y = 0 def getX(self): return self.x def setX(self,k): self.x = k def setY(self,k): self.y = k def getY(self): return self.y def diagonal(self,other): dx = self._x - other._x dy = self._y - other._y return math.sqrt(dx * dx + dy * dy)

vertex = Point() print('setting vertex at top-right of rectangle coordinates to <2,2>.') vertex.setX(2) vertex.setY(2)

xcoor=vertex.getX() ycoor=vertex.getY()

print('the top-right vertex is: <{},{}>.'.format(xcoor,ycoor))

#rectangle1=cs1graphics.Rectangle(w=ycoor*10,h=xcoor*10, centerPt=Point(0,0).midpoint(vertex*10)) #scene=Canvas() #scene.add(rectangle1) print('Prolem 2')

vertex = Point() print('setting vertex at top-right of rectangle coordinates to <2,2>.') vertex.setX(2) vertex.setY(2)

xcoor=vertex.getX() ycoor=vertex.getY()

print('the top-right vertex is: <{},{}>.'.format(xcoor,ycoor))

origin= Point(0,0)

print('The distance b/w the top right corner, {}, and the origin, {}, is {}'.format(vertex, origin, vertex.distance(origin)))

origin.normalize() vertex.normalize()

print('the normalized rectangle has vertecies on the bottom-right, {}, and the top-left, {}'.format(origin,vertex))

vertex = Point() print('setting vertex at top-right of rectangle coordinates to <2,2>.') vertex.setX(3) vertex.setY(2)

xcoor=vertex.getX() ycoor=vertex.getY()

print('the top-right vertex is: <{},{}>.'.format(xcoor,ycoor))

origin= Point(1,1)

origin.normalize() vertex.normalize()

print('the normalized rectangle has vertecies on the bottom-right, {}, and the top-left, {}'.format(origin,vertex))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago