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]
3 years ago
9

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

Computers and Technology
1 answer:
kumpel [21]3 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
Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
Serhud [2]
Driver- comes with a driver installed.
7 0
3 years ago
To view paragraph marks, click on the ______ tab, in the paragraph group, click show/hide
sergejj [24]

Answer:

Home

Explanation:

Thank Quizlet, lol!

3 0
3 years ago
Before using your Twitter account to market your personal brand, you should evaluate Your profile picture Your bio Your tweets A
AnnZ [28]
D. All of the Above.

If you are using a Twitter account for marketing your personal brand, you certainly should evaluate your entire profile, which includes your pictures, bio and tweets.  
5 0
3 years ago
Photographing during the midday can produce which of the following?
bija089 [108]

Answer:

great lighting

great emotion

great setting

great feeling

5 0
3 years ago
Short note on where do we use electronics in daily life
Nookie1986 [14]

Answer:

our laptops to do school work etc

our phones- use them everywhere

Explanation:

7 0
3 years ago
Other questions:
  • Anna always has a hard time finding files on her computer because she does not know where she saved them. This also affects her
    12·2 answers
  • Of which of the following devices are point, drag, and click actions?
    15·1 answer
  • What languages other than English are spoken in the United States?
    14·1 answer
  • Describe the differences between program development and program execution, including the installed software required for develo
    5·1 answer
  • In 2d design, form makes what possible?
    15·1 answer
  • For the function definition int SomeFunc( /* in */ int alpha, /* in */ int beta ) { int gamma; alpha = alpha + beta; gamma = 2 *
    6·2 answers
  • Consider the classes below: public class TestA { public static void main(String[] args) { ​ int x = 2; ​ int y = 20 ​ int counte
    6·1 answer
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • Se numeşte permutare a unei mulţimi finite orice rearanjare a tuturor elementelor acelei mulţimi.
    14·1 answer
  • Your friend says, “I can’t ever watch a streaming movie without it pausing for long moments. It makes me crazy!” What might you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!