Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Simple Areas by Albert.Nowak
import math
def pole_kwadratu(a,b,c):
p=(a+b+c)/2
pole= math.sqrt(p*(p-a)*(p-b)*(p-c))
return pole
def simple_areas(*args):
pi=3.14159265358979323846
list=[]
for x in args:
list.append(x)
if len(list)==1:
d=list[0]
r=d/2
pom=r**2
print(pom)
return round(pom*pi,2)
if len(list)==2:
return list[0]*list[1]
if len(list)==3:
return round(pole_kwadratu(list[0],list[1],list[2]),2)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
def almost_equal(checked, correct, significant_digits=2):
precision = 0.1 ** significant_digits
return correct - precision < checked < correct + precision
assert almost_equal(simple_areas(3), 7.07), "Circle"
assert almost_equal(simple_areas(2, 2), 4), "Square"
assert almost_equal(simple_areas(2, 3), 6), "Rectangle"
assert almost_equal(simple_areas(3, 5, 4), 6), "Triangle"
assert almost_equal(simple_areas(1.5, 2.5, 2), 1.5), "Small triangle"
Dec. 27, 2015