1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tju [1.3M]
4 years ago
9

Create a base class named rectangle that contains lenght and width data members.

Computers and Technology
1 answer:
kumpel [21]4 years ago
4 0

Answer:

class Rectangle:  

   

   def __init__(self, length, width):

       self.length = length

       self.width = width

       

   

   def area(self):

       area = self.length*self.width

       return area

   

   

class Box (Rectangle):

   

   def __init__(self, length, width, height):

       super().__init__(length, width)

       self.height = height

       

   def volume(self):

       volume = self.length * self.width * self.height

       return volume

   

   def area(self):

       area = 2*(self.length*self.width) + 2*(self.length*self.height) + 2*(self.width*self.height)

       return area

rec_1 = Rectangle(2,4)

box_1 = Box(2,2,6)

print(box_1.length)

print(box_1.area())

   

print(rec_1.length)

print(rec_1.area())

Explanation:

The programming language used is python.

class Rectangle

The class Rectangle is created with attributes length and width.

The class attributes are initialized using the __init__ constructor.

In the rectangle class, a method/function is declared to return the area of the rectangle.

class Box

This class is a child of rectangle and it inherits all its attributes and methods,

It has an additional attribute of depth and its constructor is used to initialize it.

The class contains a volume function, that returns the volume and an override function 'area()' that displaces the area from the parent class.

Finally, some instances of both classes are created.

You might be interested in
There is only one way to change line spacing in Word.
kobusy [5.1K]
False Line spacing options

Single    This option accommodates the largest font in that line, plus a small amount of extra space. The amount of extra space varies depending on the font that is used.

1.5 lines    This option is one-and-one-half times that of single line spacing.

Double    This option is twice that of single line spacing.

At least    This option sets the minimum line spacing that is needed to fit the largest font or graphic on the line.

Exactly    This option sets fixed line spacing, expressed in points. For example, if the text is in a 10-point font, you can specify 12 points as the line spacing.

Multiple    This option sets line spacing that can be expressed in numbers greater than 1. For example, setting line spacing to 1.15 will increase the space by 15 percent, and setting line spacing to 3 increases the space by 300 percent (triple spacing).

hope this help
4 0
4 years ago
A column to be used in a database is called the
Temka [501]

it is called an attribute

8 0
3 years ago
What happens when you double-click a column border??
IrinaVladis [17]
<span>The column width is adjusted to fit the text.</span>
7 0
3 years ago
Overcoming the fundamental attribution error requires making an effort to shift an external attribution into an internal attribu
Irina-Kira [14]

The correct answer on Edgen is:

(B.) False

I just took the test and this is the right answer.

8 0
4 years ago
Read 2 more answers
Generally, what is the term for storage locations in a processor?
oksano4ka [1.4K]

Answer: Registers

Explanation:

Registers are small storage locations identified by different types of registers. The function of the register is to provide data for immediate processing to the CPU. These registers hold data temporarily and provide easy access of data to the processor.

6 0
3 years ago
Other questions:
  • Mobile providers can be susceptible to poor coverage indoors as a result of: a high degree of latency. network congestion that c
    8·1 answer
  • Explain The Two Way Communication in full.
    10·1 answer
  • Are goals that<br> have concrete criteria for measuring<br> progress toward their attainment.
    5·1 answer
  • Which of the following is Microsoft’s fastest, most efficient operating system to date: a. Offering quicker application start up
    14·1 answer
  • Select the correct answer.
    9·2 answers
  • Select the correct answer.
    8·1 answer
  • What will you see on the next line?
    6·2 answers
  • Michael needs to ensure that those items that are automatically archived are still easily accessible within Outlook. Which optio
    5·2 answers
  • 1) What is y after executing the statements?
    12·1 answer
  • What is density?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!