def test_module(): print("***** Geometry Calculator *****\n", '### menu ###\n', 'p - perimeter\n', 'a - area\n', 'v - volume\n', 'b - busbar\n', 'pytha - pythagorean theorem\n') user_menu = str(input()) if user_menu == 'p': import perimeter as p print( "### perimeter - shape ###\nYou can type\nsquare, rectangle, circle, triangle, parrelleogram, circular sector, trapezoid\n" ) shape = str(input()) if shape == 'square': print("type - s") s = int(input()) print(p.square(s)) elif shape == 'rectangle': print("type - a, b") a = int(input()) b = int(input()) print(p.rectangle(a, b)) elif shape == 'circle': print("type - r") r = int(input()) print(p.circle(r)) elif shape == 'triangle': print("type - a, b, c") a = int(input()) b = int(input()) c = int(input()) print(p.triangle(a, b, c)) elif shape == 'parallelogram': print("type - a, b") a = int(input()) b = int(input()) print(p.parallelogram(a, b)) elif shape == 'circular sector': print("type - r, seta") r = int(input()) seta = int(input()) print(p.circular_sector(r, seta)) elif shape == 'trapezoid': print("type - a, b, c, d") a = int(input()) b = int(input()) c = int(input()) d = int(input()) print(p.trapezoid(a, b, c, d)) elif user_menu == 'a': import area as ar print( "### area - shape ###\nYou can type\nsquare, rectangle, circle, triangle, parallelogram, circular sector, circular ring, trapezoid, rectangular box, right circular cone, cube, cylinder\n" ) shape = str(input()) if shape == 'square': print("type - s") s = int(input()) print(ar.square(s)) elif shape == 'rectangle': print("type - a, b") a = int(input()) b = int(input()) print(ar.rectangle(a, b)) elif shape == 'circle': print("type - r") r = int(input()) print(ar.circle(r)) elif shape == 'triangle': print("type - b, h") b = int(input()) h = int(input()) print(ar.triangle(b, h)) elif shape == 'parallelogram': print("type - b, h") b = int(input()) h = int(input()) print(ar.parallelogram(b, h)) elif shape == 'circular sector': print("type - r, seta") r = int(input()) seta = int(input()) print(ar.circular_sector(r, seta)) elif shape == 'circular ring': print("type - R, r") R = int(input()) r = int(input()) print(ar.circular_ring(R, r)) elif shape == 'trapezoid': print("type - h, a, b") h = int(input()) a = int(input()) b = int(input()) print(ar.trapezoid(h, a, b)) elif shape == 'rectangular box': print("type - a, b, c") a = int(input()) b = int(input()) c = int(input()) print(ar.rectangular_box(a, b, c)) elif shape == 'right circular cone': print("type - r, s") r = int(input()) s = int(input()) print(ar.right_circular_cone(r, s)) elif shape == 'cube': print("type - l") l = int(input()) print(ar.cube(l)) elif shape == 'cylinder': print("type - r, h") r = int(input()) h = int(input()) print(ar.cylinder(r, h)) elif user_menu == 'v': import volume as v print( "### volume - shape ###\nYou can type\nsphere, rectangular box, right circular cone, cube, cylinder, frustum of a cone\n" ) shape = str(input()) if shape == 'sphere': print("type - r") r = int(input()) print(v.sphere(r)) elif shape == 'rectangular box': print("type - a, b, c") a = int(input()) b = int(input()) c = int(input()) print(v.rectangular_box(a, b, c)) elif shape == 'right circular cone': print("type - r, h") r = int(input()) h = int(input()) print(v.right_circular_cone(r, h)) elif shape == 'cube': print("type - l") l = int(input()) print(v.cube(l)) elif shape == 'cylinder': print("type - r, h") r = int(input()) h = int(input()) print(v.cyliner(r, h)) elif shape == 'frustum of a cone': print("type - r, R, h") r = int(input()) R = int(input()) h = int(input()) print(v.frustum_of_a_cone(r, R, h)) elif user_menu == 'pytha': import pythagorean as pytha print( "### pythagorean - shape ###\nYou can type\npythagorean theorem\n") shape = str(input()) if shape == 'pythagorean theorem': print("type - a, b") a = int(input()) b = int(input()) print(pytha.pythagorean_theorem(a, b)) elif user_menu == 'b': import busbar as bb print("### busbar - shape ###\nYou can type\nright circular cone\n") shape = str(input()) if shape == 'right circular cone': print("type - r, h") r = int(input()) h = int(input()) print(bb.right_circular_cone(r, h))
def main(): circle(5) square(5) rectangle(10, 2) traingle(5, 4) """c(5)
#!/usr/local/bin/python import area print('Area of circle, radius 10 =', area.circle(10))
from area import square,rectangle,triangle,circle square(10) rectangle(2,5) circle(4) triangle(2,4) list1=[101,981,'abcd','xyz','m','aman'] list2=['aman','shekhar',100.45,98.2] list3=[101,981,'abcd','xyz','m',6] print cmp(list1,list2) print cmp(list2,list1)
def main(): x = float(input('원의 지름을 입력해 주세요: ')) print('지름이 {}인 원의 면적은 {}입니다.\n'.format(x, area.circle(x))) y = float(input('정사각형의 변의 길이를 입력해 주세요: ')) print('변의 길이가 {}인 정사각형의 면적은 {}입니다.'.format(y, area.square(y)))
return math.sqrt(p * (p - a) * (p - b) * (p - c)) def rect(w, h): """ 求矩形的面积 w: 矩形的宽 h: 矩形的高 return: 面积 """ return w * h def trape(top, bottom, h): """ 求矩形的面积 top: 梯形的上底 bottom: 梯形的下底 h: 梯形的高 return: 面积 """ return (top + bottom) * h / 2 if __name__ == "__main__": import area print('半径为5的圆面积:', area.circle(5)) print('三边为3,4,5的三角形面积:', area.triangle(3, 4, 5)) print('宽为5,高为10的矩形面积:', area.rect(5, 10)) print('上底为5,下底为10, 高为8的梯形面积:', area.trape(5, 10, 8))
import strutility as st import area import packages.mdiv as md lst = list([]) for i in range(2): suls = list([]) for j in range(2): data = eval(input("Enter The Employee ID and Name")) suls.append(data) lst.append(suls) size = 0 lst1 = [] lst = ["james", "anna", "king", "smith", "kimberlee"] for i in lst: size = len(i) lst1.append(size) print(lst1) area.triangle(2, 2) area.circle(34) area.cube(32) area.cylinder(34, 56) st.concat("devesf", "bhushan") st.length("devesf", "bhushan") st.upperlowerpro("devesf", "bhushan") md.division(12, 8)
print("type - a : width / b : height") s = int(input("s :")) print(ar.square(s)) elif shape == 'rectangle': print("type - a : width / b : height") a = int(input("a :")) b = int(input("b :")) print(ar.rectangle(a, b)) elif shape == 'circle': print("type - r : radius") r = int(input("r :")) print(ar.circle(r)) elif shape == 'triangle': print("type - b : base / h : height") b = int(input("b :")) h = int(input("h :")) print(ar.triangle(b, h)) elif shape == 'parallelogram': print("type - b : base / h : height") b = int(input("b :")) h = int(input("h :")) print(ar.parallelogram(b, h))
from area import circle, square circle(10) # 314.0 square(5) # 25
import area print('Area of rectangle of 2:1 is ', end='') print(area.rectangle(2, 1)) print('Area of Circle of radius 3 is ', end='') print(area.circle(3)) print('Area of triangle with base 4 and height 5 is ', end='') print(area.triangle(4, 5)) print('Surface area of sphere with radius 7 is ', end='') print(area.sphere(7))
def test_area(self): self.assertEqual(triangle(3,2),3.0) self.assertEqual(rectangle(2,3),6.0) self.assertEqual(circle(5),78.53981633974483) self.assertEqual(square(4),16)