Rectangle Class

Lab Python Beginner 10 points

Create Rectangle(w, h) with methods area(), perimeter() and is_square(). Read the size and print the three results.

Input

One line: w h.

Output

Three lines.

Example

Input

3 4

Output

12
14
False
Sample input available Sample output available
Editor
Python

Hints

Each method uses self.w and self.h.

Solution explanation

Methods let you ask an object questions about itself.

Show solution
class Rectangle:
    def __init__(self, w, h):
        self.w = w
        self.h = h

    def area(self):
        return self.w * self.h

    def perimeter(self):
        return 2 * (self.w + self.h)

    def is_square(self):
        return self.w == self.h


r = Rectangle(*map(int, input().split()))
print(r.area())
print(r.perimeter())
print(r.is_square())
Output
Answer
HOME LEARN COMMUNITY DASHBOARD