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
Jlenok [28]
2 years ago
11

Write a Python class named Rectangle constructed by a length and width. methods it should have Area()- this should return the ar

ea as a value Perimeter()- this should return the total of all the sides as a value Print()- this should print the rectangle such that "Length X Width" Should ask the user to enter the width and length
Computers and Technology
2 answers:
melomori [17]2 years ago
6 0

Answer:

class Rectangle:

   def __init__(self, length=1, width=1):

       self.length = length

       self.width = width

   def Area(self):

       return self.length * self.width

   def Perimeter(self):

       return 2 * (self.length + self.width)

   def Print(self):

       print(str(self.length) + " X " + str(self.width))

l = float(input("Enter the length: "))

w = float(input("Enter the width: "))

a = Rectangle(l, w)

print(str(a.Area()) + " " + str(a.Perimeter()))

a.Print()

Explanation:

Create a class called Rectangle

Create its constructor, that sets the length and width

Create a method Area to calculate its area

Create a method Perimeter to calculate its perimeter

Create a Print method that prints the rectangle in the required format

Ask the user for the length and width

Create a Rectangle object

Calculate and print its area and perimeter using the methods from the class

Print the rectangle

Katen [24]2 years ago
3 0

Answer:

class Rectangle():

   def __init__(self, l, w):

       self.len = l

       self.wi  = w

   def area(self):

     return self.len*self.wi

   def perimeter(self):

     return self.len+self.len+self.wi+self.wi

   def printing(self):

     print('{} Lenght X Width {}'.format(self.len, self.wi))

length = int(input("enter the length "))

width = int(input("enter the width "))

newRectangle = Rectangle(length, width)

newRectangle.printing()

print("Area is: ")

print(newRectangle.area())

print("The perimeter is: ")

print(newRectangle.perimeter())

Explanation:

The class rectangle is defined with a constructor that sets the length and width

As required the three methods Area, perimeter and printing are also defined

The input function is used to prompt and receive user input for length and width of the rectangle

An object of the Rectangle class is created and initalilized with the values entered by the user for length and width

The three methods are then called to calculate and return their values

You might be interested in
A computer is performing a binary search on the sorted list of 7 numbers below.
suter [353]

Answer:

The answer is "Option D".

Explanation:

Binary search is also an efficient mechanism for only a sorted item list. It separates the element into one half of the checklist repeatedly, till you have narrowed it down to the only single place.

In this search, the number of comparisons is much more efficient than in the series to use the binary search approach, the items also should be shown, that's why the last choice is correct.

6 0
3 years ago
Read 2 more answers
Which of the following are breach prevention best practices?Access only the minimum amount of PHI/personally identifiable inform
Rudiy27

Answer:

All of this above.

Explanation:

All the mentioned practices can be use to prevent breaches.

6 0
3 years ago
Local variables:A. Lose the values stored in them between calls to the method in which the variable is declared
Serjik [45]

Answer:

All of the above

Explanation:

A local variable is a variable which is declared within a method or is an argument passed to a method, it scope is usually local (i.e. it is hidden from other method). it can also have the same name as a local variable in another method and it loses the values stored in them between calls to the method in which the variable is declared. So all the option listed above are correct.  

3 0
3 years ago
Mail merge requires an MS Word document in order to work.<br><br> True<br> False
Kipish [7]

True is correct. Hope it helps


3 0
3 years ago
Read 2 more answers
What is the purpose of the Arrange All command?
ladessa [460]

Answer:

allows you to see multiple workbooks at once

Explanation:

I got it right on edge 2020

8 0
2 years ago
Read 2 more answers
Other questions:
  • 1).
    12·1 answer
  • Which of the following matching is true concerning the Protocol Data Unit (PDU) and its corresponding OSI layer location?
    15·1 answer
  • What is a way to minimize technical problems with computer
    13·1 answer
  • Which of the following is NOT true about variables?
    13·1 answer
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • A(n) ____________________ is hardware or software that blocks or allows transmission of information packets based on criteria su
    13·1 answer
  • What is the purpose of the operating system's processor management function?
    14·1 answer
  • Let’s say you attach four images to accompany an important tweet that you’ve composed in the Hootsuite Compose Box. On Twitter,
    8·1 answer
  • Melanie needs to ensure that readers are able to locate specific sections within a document easily. What should she include in
    8·1 answer
  • Create a text file content.txt and copy-paste following text (taken from Wikipedia) into it: A single-tasking system can only ru
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!