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
8.2 code practice edhesive?
Illusion [34]

Answer:

temperatures = []

i = 0

while i < 5:

   try:

       t = int(input('Enter a temperature: '))

       temperatures.append(t)

       i += 1

   except ValueError:

       print('Enter a number')

print(temperatures)

Explanation:

Hope this helps!

6 0
3 years ago
What is the promotion and advertising stage of a product or service called?
Eddi Din [679]

Answer:

Marketing

Explanation:

8 0
3 years ago
What does an SQL injection do
Afina-wow [57]

Answer:

SQL injection is a form of hacking that uses user input fields.

Explanation:

SQL injection is when a piece of code or entire algorithm is input where a program prompts for user input. They can be used to change or access data. To prevent this, a programmer should scrub inputs. Scrubbing data removes slashes and arrows, which or commonly used in code.

3 0
2 years ago
Read 2 more answers
(tco 3) what vbscript boolean operator could be used to replace the nested selection structure in this pseudocode? if empmedical
Leto [7]
You want both conditions to be true, so you can "And" them.
In vbscript, the and is written as "And" (not as && like other languages), so you get:

<span>If (empmedicalins = "y") And (empdentalins = "y") Then
    print empidnumber, emplastname, empfirstname
Endif</span>
3 0
3 years ago
I need someone's opinion<br> Which format is better? The first or second one? I can't decide 0.0
Ne4ueva [31]

Answer:

2nd one

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Patient letters created from __________ use structured data and do not require a large amount of typing from the medical assista
    8·1 answer
  • When you are working on an unsaved document on a PC, where is the document temporarily saved?
    5·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    12·1 answer
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • Is this a Bad Cpu processor ? I need some.help ASAP I turn on my.pc and it has no display but everything is on fans and the you
    13·1 answer
  • What is the main feature of chat rooms?
    9·2 answers
  • A signal has a wavelength of 1 11m in air. How far can the front of the wave travel during 1000 periods?
    7·1 answer
  • What is the maximum ream size on an agile project?
    15·1 answer
  • I need subscribers plz ​
    15·2 answers
  • Hey, how do we get our warnings removed? I got one and I didn't realize that what I did was wrong.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!