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
Identify congruent triangles. Justify why these triangles are congruent?
dem82 [27]
4 because it’s a triangular ruler
3 0
2 years ago
In computer science what are the methods used to protect the information stored by a piece of software called?
Nezavi [6.7K]

Answer:

cryptography

Explanation:

cryptography

In computer science, cryptography refers to secure information and communication techniques derived from mathematical concepts and a set of rule-based calculations called algorithms, to transform messages in ways that are hard to decipher

3 0
3 years ago
Which structures protect the cell? Select two options.
Rzqust [24]

Answer:

cell wall

cell membrane

3 0
2 years ago
The question is in the photo
Anastaziya [24]

Answer:

a

the most suitable answer

8 0
3 years ago
what are the advantages of breaking up a single logical message into a number of fixed-sized packets and then sending each one o
aleksklad [387]

Explanation:

These are the advantages of breaking up a single logical message into a number of fixed sized packets.

- When messages are broken into packets it increases the performance and also the reliability of the internet

- if there is an error in a single packet, this error is not going to affect the entire message.

- the efficiency of the communication line in the internet is improved.

- there is a reduction of traffic. Each packet in a single message can be transmitted through different routes.

- It reduces idleness as each packet can send from different program so each program has a service.

8 0
2 years ago
Other questions:
  • The two types of one-time-password tokens are ______ and ______.
    10·2 answers
  • This diagram shows a number of computing devices connected to the Internet with each line representing a direct connection.
    11·1 answer
  • Please describe in a few sentences
    14·1 answer
  • Help meee pleaseeee
    5·1 answer
  • Technical term of stealing personal information in social media.​
    5·1 answer
  • ANSWER QUICKLY PLEASE
    7·1 answer
  • Select the correct answer. Which sign or symbol will you use to lock cells for absolute cell reference?
    9·2 answers
  • It took her 9 more months but Marina has managed to save the full $725 plus more to cover fees to pay off the pay-day loan compa
    9·1 answer
  • You often need to have several applications open at the same time. Which requirement is related to this need?
    11·1 answer
  • Differentiate between patent and copyright.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!