Rectangle Area
Python
Easy
2 views
Problem Description
Length and width are provided. Create Rectangle class with area() method. Output area as integer.
Input Format
One line: L W.
Output Format
One integer area.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if len(p)<2: sys.exit(0)
L=int(p[0]); W=int(p[1])
class Rectangle:
def __init__(self,l,w):
self.l=l
self.w=w
def area(self):
return self.l*self.w
sys.stdout.write(str(Rectangle(L,W).area()))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!