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
Eric’s computer slows down when he open several computer programs. Why does this happen?
Genrish500 [490]

A. Eric has limited RAM space

Since Eric doesn't have a lot of RAM space he won't be able to open up several programs at once

4 0
3 years ago
Read 2 more answers
Explain how it makes you feel that you must share the road with others
Tpy6a [65]
I feel like it is good to share the road.

8 0
3 years ago
"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "
Monica [59]

Question:

"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "

A) a[0]..a[a.length]

B) a()

C) a

D) a[]  

Answer:

The correct answer is A.

An example is given in the attachment.

Cheers!

4 0
3 years ago
Which term accurately describes agile and devops
Elza [17]

Answer:

Answer: Agile is refers to an interative approuch which focuses on collaboration, costumer feedback,and small rapid releases,DevOps is considered a practice bringing development and operations teams together

Hope this is helpful for you

7 0
3 years ago
Which of the following is an example of a syntax error?
Yuri [45]

Answer:

misspelling a programming language word

Explanation:

Syntax error is the type of error in programming, when the programmer insert some symbol that is not present in directories or libraries, the programmer not followed the rules of that particular programming language that is understandable to compiler.

For example in C++, it is necessary to insert the semicolon (;) after each statement. If the programmer not insert the semicolon after each statement, the program will show the syntax error.

If the programmer use integer instead of int to assign datatype to the variable in C++, it will also leads to the syntax error. Because in C++ library, Integer is defined with the help of "int".

4 0
3 years ago
Other questions:
  • In a PowerPoint presentation, it is not possible to add notes that are hidden from the audience's view.
    9·1 answer
  • Select the correct statement below. Group of answer choices
    6·2 answers
  • Diane wants to maintain a record of percent change in sales from the year 2000 to the present year. She enters the values of per
    10·1 answer
  • Which of the following experiences is considered a simulation?
    12·1 answer
  • I NEED IT NOWW
    13·2 answers
  • Which platform is dedicated to Customer Relationship Management (CRM)?
    7·1 answer
  • What type of error occurred??
    10·1 answer
  • A compound Boolean expression created with the _________ operator is true if either of its subexpressions is true.
    11·1 answer
  • A homeowner uses a smart assistant to set the house alarm, get packages delivery updates, and set time on the outdoor lights. Wh
    14·1 answer
  • Give 5 characteristics of bad capacitor<br> give 5 characteristics of good capacitor
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!