Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me in python! CSc 131 CSC 131-Computational Thinking Lab 4 Write the code for a class named Point to represent a point in the

Help me in python! image text in transcribed
CSc 131 CSC 131-Computational Thinking Lab 4 Write the code for a class named Point to represent a point in the Cartesian plane with x and y coordinates. The class contains: Two instance variables x and y that represent the coordinates with getX0 and getYO methods. .A constructor that constructs a point with specified An strmethod to return a string representation in the form (x, y). .A method named distance that returns the distance from t coordinates, with default values 0 and 0. is point to another point. The formula for finding the distance between the two points (xl,y1) and (x2,y2) is math sqt . A method named originDistance that returns the distance from this point to the point of origin (0,0) Appropriate code so that points can be compared using the comparison operators. Points are compared based on their distance from the origin Add a test program that does the following: . Creates a point object, named po, that uses the default values for the coordinates Print p Creates a point object, named p1, with coordinates at (34) Print p a point object, named p2, with coordinates at (3,0). When creating the object, take advantage of the fact that the value of the y-ccordinate is the default value of the corresponding parameter. Print the x and y coor of p2 using the getXO and getYO methods Find and print the distance between pl and p2 Print the results of comparing pl and p2. Make sure to test all 6 comparison operators . Your code should allow using and1 to compare a Point object with an object of a different type. Print the result of using the equality and inequality operators to compare pl with the string "Hello Name your file lab4.py. Make sure to include your name and the name of your TRACE folder at the top of the file in a docstring. When you are done, demonstrate your code to the instructor and upload your solution in your CSC131 upload folder in a folder called LABSJab4 888 a

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

What event prompted Ginas first symptoms of bipolar disorder?

Answered: 1 week ago

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago