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
Write a program that reads in a list of numbers, and for each number, determines and prints out whether or not that number is ab
adelina 88 [10]
int IsAbundant(int n)
{
int divisorSum = 0;
for (int i = 1; i < n; i++) {
 if ((n % i) == 0) {
  divisorSum += i;
 }
}
return divisorSum > n;
}


int main()
{
int number = 0;
do {
 printf("Enter a number (0 to quit): ");
 scanf_s("%d", &number);
 if (IsAbundant(number)) {
  printf("%d is abundant!\n", number);
   } else
   {
    printf("%d is not abundant.\n", number); }
   } while (number > 0);

   return 0;
}

7 0
3 years ago
Jeff types a sentence She wore a new dress yesterday. He erroneously typed w instead of e in the word dress. What is the accurac
antoniya [11.8K]
96 i believe i'm not too certain on this one
6 0
3 years ago
Read 2 more answers
Technology progress so new needs can be satisfied
snow_lady [41]

Yes, that is definitely true.

7 0
3 years ago
Read 2 more answers
If your computer will not turn on, What is something you can would you use to diagnose the problem?
inysia [295]
3. See if its plugged in
3 0
3 years ago
Read 2 more answers
Silly Sayings is seeing a lot of website traffic, but the company wants to generate more qualified leads. They’re interested in
notsponge [240]

Answer:

The way ad extensions can assist companies like such as Silly Sayings in generating more qualified leads is:

D. By providing users with relevant information up-front.

Explanation:

  • Silly Saying wants to generate more qualified leads on the website as the demand of the company. So, they can use add extension to accomplish their goal by providing the relevant information up-front so that the potential customer don't get distracted and converts into the qualified lead.
  • The add extension helps you to add information like contact number and you can add a link. This makes you add more interesting and motivates the customer to click to accomplish your goal.
  • The other options like presenting user with catalog options for a product or by dynamically using negative keywords, based on user's website content or by attracting user with creative assets are the passive approaches which has cause them to generate unqualified leads.

8 0
3 years ago
Other questions:
  • Using powerpoint 2016, ethan develops a short five-slide presentation for his marketing project. â â powerpoint files consist of
    6·1 answer
  • When admitting digital evidence at trial, the issue of ________ comes up when the evidence involves computer-generated records.
    13·1 answer
  • How can you create the first row of the table as the header of the table?
    14·2 answers
  • (50 points) Write a programthat adds the first and last elements of an integer array and stored as the first element of the outp
    12·1 answer
  • Easy Bib and Cite This For Me are examples of online
    12·1 answer
  • Interruption attacks are also called ___ attacks:
    8·1 answer
  • T or F: Is there such thing as an OptiPlex 3020
    12·1 answer
  • The radix sort
    7·1 answer
  • Question 17 (3 points)
    10·1 answer
  • Suppose your team is finishing a project and the supervisor stresses ensuring the material cannot be erased. To what memory leve
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!