Question: 1 . Create Point class Create a Point class that has both an x and a y attribute. Think of it as the representation of
Create Point class
Create a Point class that has both an x and a y attribute. Think of it as the representation of a point on an xy coordinate graph.
Create a class with the following properties:
The class name is Point
It has the attributes x and y which are both floats
Now, define a constructor aka an init method that takes as input xinit: float and yinit: float and assigns those as the initial values for the attributes x and y
Mutating Method: Point#scaleby
Write a method that belongs to the Point class and mutates a Point.
Itll should the following properties:
Method name: scaleby
Parameters: self and factor: int In general, the first parameter of a method should always be self
Return Type: None
Behavior: It should update the x and y attributes so that x x factor and y y factor
Mutating Method: Point#scale
Write a method that belongs to the Point class and instead of mutating a Point, it creates a new Point.
Itll should the following properties:
Method name: scale
Parameters: self and factor: int In general, the first parameter of a method should always be self
Return Type: Point
Behavior: It should return a new Point with x and y attributes equal to self.x factor and self.y factor.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
