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
Write a program in qbasic to accept a character and check it is vowel or consonant​
Alborosie

Answer:

In sub procedure or normal program?

6 0
3 years ago
a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
Usimov [2.4K]
You yourself put the answer to the question in the Question. the answer is paragraph. lol
7 0
3 years ago
Read 2 more answers
What is commodity? explain
timama [110]
A raw material or primary agricultural product that can be bought and sold, such as copper or coffee.
6 0
3 years ago
Which of the following are incorrect safety precautions for equipment operators? A. Drive equipment or vehicles on grades or roa
Zarrin [17]
Hello!

The correct answer would be: D. Should not exceed a vehicle's rated load or life capacity.

I hope you found this helpful! :)
3 0
3 years ago
Read 2 more answers
1. Briefly explain the concept of signature of a function, in a function declaration. What signature components are crucial for
Irina18 [472]

Answer:

Function signature can be defined as a combined term used to refer to the function name, function return type, no of arguments , type of arguments.

Explanation:

The signature of function is seen as a combined term used to refer to the function name, function return type, number of arguments , type of arguments.

When overloaded functions is been defined, they are different in numbet of arguments or type of argument passed.

To understand this better refer to the program code below.

C++ code.

#include <iostream>

using namespace std;

int multiply(int a, int b)

{

cout << a*b <<endl;

return 0;

}

int multiply(int a, int b, int c)

{

cout << a*b*c <<endl;

return 0;

}

int main()

{

//function with two arguments passed

multiply(3, 50);

//function with three arguments passed . It is different in number of arguments passed. Thus here function signature is different

multiply(4, 20, 10);

}

6 0
3 years ago
Other questions:
  • Does time complexity depend on, which base arithmetic you use? like base 10, 2 or whatever else? Does time coplexity depned on t
    13·1 answer
  • How do you make your graphics ADA accessible in BlueGriffon?
    12·2 answers
  • Problem 3. Consider the following recurrence, defined for n a power of 4 (for the time of some algorithm): T(n) = 3 if n = 1 2T(
    5·1 answer
  • Which of the following is the definition of registration authority ( RA)?
    10·1 answer
  • Along a road lies a odd number of stones placed at intervals of 10 metres. These stones have to be assembled around the middle s
    12·1 answer
  • Why are mobile phone called cell phones?​
    13·1 answer
  • Which of the following is a key difference between a Windows 7 restore point and one you set yourself?
    11·1 answer
  • One of your suppliers has recently been in the news. Workers complain of long hours, hot and stuffy workrooms, poor lighting, an
    15·1 answer
  • What are the main types of database end users,? Discuss the main activi-ties of each
    10·1 answer
  • What's the best item in the binding of isaac?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!