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]
3 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]3 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]3 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 database that is created and maintained using services such as Microsoft Azure or Amazon AWS is called a(n) _____ database.
Phantasy [73]

Answer:

It is called a cloud database

5 0
2 years ago
Steve is happy today but he ____ yesterday​
suter [353]

steve is happy today but he wasn't yesterday

3 0
2 years ago
Read 2 more answers
Which of the following would you not see on a windows 10 start menu?
mixas84 [53]
Task view is the option that you would not see on a Windows 10 Start menu, whereas if you click the Windows button, you can see tiles with different applications, all of your apps in the form of tiles you can distribute according to your own taste, and power button where you can choose whether you want to shut down your computer, put it to sleep, or log out.
4 0
2 years ago
What will happen if you type pseudocode in another language's programming environment and try to run the
wariber [46]

Answer:

You will get compile error

Explanation:

7 0
3 years ago
Can you help please ill give branilist
konstantin123 [22]

HTML uses tags to help the computer know what different pieces of content in the web page actually are. Right now we've only learned how to tell the computer that some text is a paragraph, or that part of your website is the body. We've already seen how that affects the way our web pages look and are structured.

(I don't know how it should be organized, but hope this helped)

3 0
2 years ago
Other questions:
  • Need Help ASAP!
    14·2 answers
  • In an advanced word processing program which type of image or graphic is available in a variety of formats and styles?
    12·2 answers
  • Write a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in
    5·1 answer
  • "background" software that helps the computer manage its own internal resources is called ________.
    5·1 answer
  • PLEASE HELP!!!!!!!!!!
    15·2 answers
  • Assume you are given a boolean variable named isNegative and a 2-dimensional array of ints that has been created and assigned to
    8·1 answer
  • How to write cube of a number from flowchart ​
    5·1 answer
  • Select the correct answer.<br> What do you understand by "exposition"?
    10·2 answers
  • All _______ that store more than one piece of data ​
    12·1 answer
  • Fill in the blanks with the correct words.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!