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
Which one is not an operating system?1.mac 2.Microsoft office3.Iso.3.Android
quester [9]
It's either microsoft or office. Based on research I would say office.

I really hope this helps you! :-)
6 0
3 years ago
Write a loop statement to count and display the number of positive integers in the array. That is, your loop should display the
dlinn [17]

Answer:

int count =0;

    for(int i=0;i<10;i++)

    {

        if(myArray[i]>=0)

        {

            count++;

        }

    }

    cout<<"Number of positive integers is "<<count<<endl;

Explanation:

The above written loop is for counting positive integers in the myArray[].

For counting we have taken a count integer initialized with 0.On iterating over the array if the element is greater than or equal to 0 we consider it as positive and increasing the count.At the end printing the count.

3 0
3 years ago
The four smallest numbers (40 points) Write an ANNA assembly program (smallest_four.ac) that finds the four smallest numbers ent
kari74 [83]

Answer:

the answer is -25

Explanation:

6 0
2 years ago
What is the system that consists of nonproprietary hardware and software based on publicly known standards that allow third part
il63 [147K]

Answer:

Open systems

Explanation:

Open systems are very different from Open Source applications or software, it should not be confused.

Open systems work with the blend of open software standards, portability, and interoperability. Computer systems that interoperate among multiple standards and vendors to ensure that computer resources (hardware and software) are not allotted to a particular vendor. Such computer systems are considered as open systems.

For instance, computer systems that run a Microsoft Windows OS can be considered as an Open system. This is because of their capability to run different versions of the Microsoft Windows OS on that particular computer system. More clearly, A computer with Windows 10 OS, can be used to install Windows 8 OS without any issue. That same computer system can run the Windows 7 OS. This makes the computer system and open system.

5 0
2 years ago
Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is: 2000 2
STatiana [176]

Answer:

// here is code in c++.

// include header

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables to read input

   int userNum,x;

   cout<<"enter the value of userNum and x :";

   // read the input from user

   cin>>userNum>>x;

   // divide the userNum with x 4 times

   for(int a=0;a<4;a++)

   {

       userNum=userNum/x;

       cout<<userNum<<" ";

   }

       cout<<endl;

return 0;

}

Explanation:

Declare two variables "userNum" and "x". Read the value of these. Run a for loop 4 time and divide the "userNum" with "x" and print  the value of "userNum".

<u>Output:</u>

enter the value of userNum and x :2000 2                                                                                  

1000 500 250 125  

3 0
3 years ago
Other questions:
  • Calculated fields can be entered in queries. What row should you type a calculated field in?
    13·1 answer
  • You're trying to improve an ad's perceived quality so it performs better during an ad auction. What change would have the least-
    15·1 answer
  • Maria is developing an online gaming website. She is working on an interactive game that has a central character guiding the vis
    14·2 answers
  • The user enters a URL into a web browser, the web browser sends the information to the DNS server to look up the IP address, the
    12·1 answer
  • How did the military in the early 1900s move resources?
    7·1 answer
  • What is the benefit of making an archive folder visible in the Outlook folder list?
    6·1 answer
  • Difference between customized and packaged software​
    10·1 answer
  • There are some games that cannot be described by a single--or even two-- genres. Can you think of any that should be invented?​
    6·1 answer
  • a ____ is a window inside the word window that can remain open and visible while you work in a document.
    14·1 answer
  • What is keyword density?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!