Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python question! I keep getting an error for a class and function I'm creating in python. The error is unsupported operand type(s) for -: 'method'

Python question!

I keep getting an error for a class and function I'm creating in python. The error is "unsupported operand type(s) for -: 'method' and 'int'"

here's a small segment of the code below

The error is happens in the return line under defining distance function. I'm not sure how to fix the problem. I didn't include the entire class because it seemed irrelevant to my specific question. It seems there's some sort of error when assigning values to x1, x2, y1, and y2 and implementing it into the define function. maybe it isn't reading the input values as integers? i've tried a few things and i can't seem to figure it out.

Edit: the indents are correct on my .py file, I'm not sure how to indent in chegg

def distance(x1, y1, x2, y2): return math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))

def main(): x1,y1,radius1 = eval(input("Enter x1, y1, radius1: ")) x2,y2,radius2 = eval(input("Enter x2, y2, radius2: ")) c1 = Circle2D(x1, y1, radius1) c2 = Circle2D(x2, y2, radius2) print("Area for c1 is", c1.getArea()) print("Perimeter for c1 is", c1.getPerimeter()) print("Area for c1 is", c2.getArea()) print("Perimeter for c2 is", c2.getPerimeter) print("c1 contains the center of c2?", c1.containsPoint(c2.getX, c2.getY)) print("c1 contains c2?", c1.contains(c2)) print("c1 overlaps c2?", c1.overlaps(c2))

main()

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions