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
Who created Microsoft​
saveliy_v [14]

Bill Gates and Paul Allen

6 0
3 years ago
Read 2 more answers
What’s the difference between the alternative press and a tabloid?
miskamm [114]

Answer:

Alternative Press just differs in opinion from mainstream media. A tabloid is literally smaller and is contains sensationalist and largely photographic content.

Most alternative presses aren't reliable and are effectively tabloids in nature, but their content differs.

4 0
2 years ago
Plz help code practice for python
laila [671]

Answer:umm

Explanation:

6 0
3 years ago
Read 2 more answers
Which social networking website is credited for being the fastest site to cross the 10 million unique-visitor mark?
Vikentia [17]
The correct answer is B Pinterest was credited for being the fastest site to get 10 million unique visitors
7 0
3 years ago
Read 2 more answers
In Office Online apps, the ribbon appears in
bonufazy [111]
I think the answer is C

hope this helps :)
7 0
3 years ago
Read 2 more answers
Other questions:
  • 1. It is a requirement to install a routing protocol that monitors the network for routers that have changed their link state. T
    13·1 answer
  • Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max
    5·1 answer
  • Using the Sakila database, create a query that displays the film title, description, as well the actor first and last name for a
    12·1 answer
  • When dealing with a person who is behaving violently you should argue with them. A. False B. True
    5·1 answer
  • What type of message authentication code uses hashing to authenticate the sender by using both a hash function and a secret cryp
    10·1 answer
  • What do rocket scientists mean when they say, "forces come in pairs?"
    7·1 answer
  • The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
    14·1 answer
  • Explain why there are fundamental ideas of software engineering that apply to all types of software systems.
    7·1 answer
  • Which of the following is not a bus type A. Address bus B. Data bus C. Memory bus D. Control bus ​
    7·2 answers
  • Complete the sentence with the correct response.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!