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
For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period to achieve this rate of
maks197457 [2]

Answer:

The Python code is given below with appropriate comments

Explanation:

def predict_population_growth():

#Prompt and read the input from the user

num_org = int(input("Enter the initial number of organisms: "))

GR = float(input("Enter the rate of growth [a real number > 0]: "))

numHour = int(input("Enter the number of hours to achieve the rate of growth: "))

totalHours = int(input("Enter the total hours of growth: "))

#caluclate the total poulation growth

population = num_org

hours = 0

while hours < totalHours:

    population *= GR

    hours += numHour

print(" The total population is " + str(int(population)))

predict_population_growth()

6 0
3 years ago
To protect yourself from the risk of product failure, what strategy could you use?
Sloan [31]

I would move the file into a folder and zip it or move the it into a flash drive

5 0
3 years ago
Ally is taking a photograph of her friend. What is the orientation of her phone's screen?
In-s [12.5K]

Answer:

portrait

Explanation:

?

8 0
3 years ago
Please help!!!! will mark brainliest!!
fgiga [73]

Answer:

1. Speaking or texting on the cell phone while driving.

= It cause an accident.

2. Using technology for bullying others.

Hope this answer will help you.

7 0
3 years ago
Read 2 more answers
Place Letter or word in correct section where it says labels bellow
love history [14]
A beauty its not b c or d
3 0
3 years ago
Read 2 more answers
Other questions:
  • After applying transitions to his presentation, Omar uses the Slide Show feature to view the them. He notices that the transitio
    9·2 answers
  • What is output by the following?<br><br>print (type("95"))
    13·1 answer
  • Where can I easily find an easy app or program to use for making/editing videos?
    13·1 answer
  • Please write down a java program for below instruction.Min-Heap: Construct a Min_Heap from the following set of integers. Rememb
    5·1 answer
  • In most cases, it is possible to prevent an exception from terminating a program by using the try and except statements. Select
    13·1 answer
  • 1. Write a programme to print the Fees Receipt of English High School Required Inputs Name of the Student Monthly Tuition Fees M
    10·1 answer
  • I need help with computer science<br> the quiz on e2020 is on hackers and unauthorized access
    15·2 answers
  • The distance between two walls is called what?
    8·2 answers
  • The abuse of children is a symptom of
    6·2 answers
  • How do i stop my computer from automatically connecting to a wireless network
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!