Problem 3: Rectangle Area and Perimeter Class
Easypython
Learn the Concept: OOP BasicsProblem Description
Create a class Rectangle with attributes length and width. Add two methods: area() that returns the rectangle's area, and perimeter() that returns its perimeter.
Input
Length and width of a rectangle.
Output
The calculated area and perimeter.
Constraints
- Both
lengthandwidthare positive numbers.
Example Input
textlength = 5, width = 3
Example Output
textArea: 15 Perimeter: 16
Concepts Covered
Classes, __init__, methods, return, arithmetic operations.
Related Problems
- Problem 1: Simple Book ClassEasy · pythonSolve Problem
- Problem 2: Bank Account ClassEasy · pythonSolve Problem
- Problem 4: Multiple Student Objects ComparisonEasy · pythonSolve Problem