# Scientific Computing with Python Projects - Polygon Area Calculator

Tell us what’s happening:
Describe your issue in detail here.

I get an AssertionError.
AssertionError: ‘Rectangle(width=8,height=6)’ != ‘Rectangle(width=7, height=8)’

• Rectangle(width=8,height=6)
? ^ ^
• Rectangle(width=7, height=8)
? ^ + ^
: Expected string representation of rectangle after setting new values to be “Rectangle(width=7, height=8)”

class Rectangle:
def init(self, width, height):
self.width = width
self.height = height
self.picture = (‘*’ * self.width + ‘\n’) * (self.height)

def get_area(self):
return self.width * self.height

def get_perimeter(self):
return 2 * self.width + 2 * self.height

def get_diagonal(self):
return (self.width ** 2 + self.height ** 2) ** 0.5

def set_width(self,new_width):
self.width = new_width

def set_height(self,new_height):
self.width = new_height

def get_picture(self):
return self.picture

def get_amount_inside(self,shape):
return self.get_area() // shape.get_area()

def str(self):
return f"Rectangle(width={self.width},height={self.height})"

class Square(Rectangle):
def init(self,side):
self.width = side
self.height = side
super().init(side,side)
def set_side(self,new_side):
self.width = new_side
self.height = new_side
self.picture = (‘*’ * new_side + ‘\n’) * new_side
def str(self):
return “Square(side={})”.format(self.width)

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188`

Challenge: Scientific Computing with Python Projects - Polygon Area Calculator

Hi! The problem seems to be the use of quotes (‘ and ’) in your code. In Python, it is correct to use single (``) or double (`"`) quotes to create strings.

or

This is probably the reason for the error you described

Actually that seems to happen when you paste code onto the forum without putting it in ‘pre-formatted’ blocks `like 'this'` or

like ‘this’

The problem is that the rectangle is the wrong size/shape. It’s 8 by 6 instead of 7 by 8.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.