-
Notifications
You must be signed in to change notification settings - Fork 73
/
figureout.python
42 lines (34 loc) · 889 Bytes
/
figureout.python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/python3
import math
import os
import random
import re
import sys
class Rectangle:
def _init_(self,l,b):
self.l=l
self.b=b
def area(self):
return self.l*self.b
class Circle:
def _init_(self,r):
self.r=r
def area(self):
return math.pi*self.r*self.r
if _name_ == '_main_':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(input())
queries = []
for _ in range(q):
args = input().split()
shape_name, params = args[0], tuple(map(int, args[1:]))
if shape_name == "rectangle":
a, b = params[0], params[1]
shape = Rectangle(a, b)
elif shape_name == "circle":
r = params[0]
shape = Circle(r)
else:
raise ValueError("invalid shape type")
fptr.write("%.2f\n" % shape.area())
fptr.close()