Page 76 - tp_Modula_v2.0
P. 76

Program  14: To check whether  the triangle given by the user is scalene, isosceles  or

                  equilateral.
                      Program14.py
                   File  Edit  Format   Run   Options  Window    Help


                   def calculate_area (name):
                       name = name.lower()
                       if name == "rectangle":
                           length = int(input("Enter the length of rectangle: "))
                           breadth = int(input("Enter the breadth of rectangle: "))
                           rect_area = length * breadth
                           print("The area of rectangle is: ", rect_area)
                       elif name == "square":
                           S = int(input("Enter square's side length: "))
                           sqt_area = s * s
                           print("The area of square is: ", sqt_area)
                       elif name == "circle":
                           r = int(input("Enter the radius of circle: "))
                           pi = 3.14
                           cic_area = pi * r * r
                           print("The area of circle is: ", cic_area)
                      elif name == "triangle":
                           b = int(input("Enter the base length of a triangle: "))
                           h = int(input("Enter the height of a triangle: "))
                           tri_area = 0.5 * b * h
                           print("The area of triangle is: ", tri_area)
                       else:
                           print("The shape is not available")
                   print("Calculate the shape area")
                   shape_name = input("Enter the shape whose area you want to find:")
                   calculate_area(shape_name)



                  On running the above program, you will get the following output:
                      Output

                   Calculate the shape area
                   Enter the shape whose area you want to find:rectangle
                   Enter the length of rectangle: 5
                   Enter the breadth of rectangle: 5
                   The area of rectangle is:  25

                   Calculate the shape area
                   Enter the shape whose area you want to find:square
                   Enter square's side length: 5
                   The area of square is:  25

                   Calculate the shape area
                   Enter the shape whose area you want to find:circle
                   Enter the radius of circle: 5
                   The area of circle is:  78.5

                   Calculate the shape area
                   Enter the shape whose area you want to find:5
                   The shape is not available



                   74     Touchpad MODULAR (Version 2.0)
   71   72   73   74   75   76   77   78   79   80   81