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
1
brilliants [131]

Answer:

The appropriate answer is "Distributed system".

Explanation:

  • Whenever used by linking several autonomous computers as a single system, considered as distributed system. It could be consist of several kinds of  mainframes, processors as well as stationary machines, it can be programmed.
  • A distributed machine has massive program modules, which operate as a single device on many machines.
6 0
3 years ago
Suppose we perform a sequence of n operations on a data structure such that if some condition C(k) holds then the kth operation
GrogVix [38]

Answer:

stay home, stay safe, dont get corona virus

Explanation:

7 0
3 years ago
Which tool is used to test electrical current within a source of power, like a power supply?
yawa3891 [41]

Answer:

Multimeter

Explanation:

A multimeter or multitester or VOM (volt-ohm-milliammeter), is a tool to measure electricity and this tool has some function to measure voltage, current, and resistance. We could find analog and digital multimeters, and we can find expensive certificates and professionals multimeters ($5,000) or cheap ($10).

5 0
3 years ago
What is one benefit of using electronic sticky notes ?
balu736 [363]
They can be used to just copy/paste e-mailed information without writing down on a paper and losing valuable time. This is one example.
4 0
3 years ago
Read 2 more answers
If you get musicilly can your parents see
Tresset [83]
I wouldn't think so unless they have access to your phone or account. But I don't believe this is school related.
6 0
3 years ago
Read 2 more answers
Other questions:
  • In this type of network, data is certain to reach its destination.
    7·1 answer
  • Which software can managers use to discuss financial performance with the help of slides and charts?
    7·2 answers
  • The three tasks within data harmonization, namely: data consolidation, data cleansing, and data formatting use techniques called
    8·1 answer
  • What’s bigger 4,000,000 KB or 2.8 GB
    5·2 answers
  • 1. Insert a Header that has the following in excel​
    14·1 answer
  • What is computer code?<br> A. Java Script<br> B. XML<br> C. HTML<br> D. Any programming language
    6·1 answer
  • Please Help, Thank you!
    5·1 answer
  • What is a trojan horse
    8·2 answers
  • When do you use an else statement?
    10·1 answer
  • Program Convert Measurements:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!