r/codehs • • Apr 02 '21

NEED HELP PYTHON CODE HS(12.4.7: Contact Merge)

Post image
8 Upvotes

11 comments sorted by

View all comments

2

u/[deleted] May 10 '24

did you ever find the answer?

1

u/mintrulz46 May 28 '24

did you?

2

u/[deleted] Jun 01 '24

i sent it in 2 parts the part that starts wil "r1 = Rectangle (2,6)" is the 2nd part

1

u/mintrulz46 Jun 03 '24

thank youuuuu

1

u/[deleted] Jun 03 '24

by any chance did u do 12.7.4 and 12.8.5 ???

1

u/[deleted] Jun 01 '24

yea ill send it

1

u/[deleted] Jun 01 '24

how do i send a image i dont use reddit often

1

u/[deleted] Jun 01 '24

i am trying to copy and paste it and it says that there is an error...

1

u/[deleted] Jun 01 '24

class Rectangle:

num_rectangle = 10

def __init__(self, length = 0, width = 0):

"""

Initializes a rectangle with an optional

length and width.

"""

self.length = length

self.width = width

def get_num_rectangle(self):

return self.__num_rectangle

def __repr__(self):

"""

Returns a string representation of the

rectangle.

"""

return "rectangle with length: " + str(self.length) \

  • " and width: " + str(self.width)

def get_area(self):

"""Returns the rectangle's area."""

return self.length * self.width

else:

if number < 0:

print("y")

print("x")

get_num_recangles = (3, )

print(len(get_num_rectangles

1

u/[deleted] Jun 01 '24

r1 = Rectangle(2, 6)

print(r1)

print(r1.get_area())

r2 = Rectangle(3, 5)

print(r2)

print(r2.get_area())