Wednesday, 21 April 2021

Python Program : 2 : Compute area of following shapes: circle, rectangle, triangle, square, trapezoid and parallelogram.

PROGRAM :-
import math
PI = math.pi
print("------------------------------")
print("  ....Enter your choice....")
print("whose area u want to calculate")
print("------------------------------")
print("\t1. CIRCLE")
print("\t2. RECTANGLE")
print("\t3. TRIANGLE")
print("\t4. SQUARE")
print("\t5. TRAPEZOID")
print("\t6. PARALLELOGRAM")
print("------------------------------")
n = int(input("Enter your choice : "))
if n == 1:
    r = int(input("Enter Radius : "))
    A1 = PI*r*r
    print("Area of Circle : ",round(A1,2))
elif n == 2:
    s1 = int(input("Enter Length of Rectangle : "))
    s2 = int(input("Enter Breadth of Rectangle : "))
    A2 = s1*s2
    print("Area of the Rectangle : ",round(A2,2))
elif n == 3:
    a = int(input("Enter first side : "))
    b = int(input("Enter second side : "))
    c = int(input("Enter third side : "))
    s = (a+b+c)/2
    temp = s*(s-a)*(s-b)*(s-c)
    A3 = math.sqrt(temp)
    print("Area of the Triangle : ",round(A3,2))
elif n == 4:
    side = int(input("Enter side of square : "))
    A4 = side*side
    print("Area of the Square : ",round(A4,2))
elif n == 5:
    P1 = int(input("Enter first parallel side : "))
    P2 = int(input("Enter second parallel side : "))
    D = int(input("Enter Distance between || sides : "))
    A5 = 0.5 * (P1+P2) * D
    print("Area of the Trapezoid : ",round(A5,2))
elif n == 6:
    base = int(input("Enter base of parallelogram : "))
    height = int(input("Enter height : "))
    A6 = base*height
    print("Area of the Parallelogram : ",round(A6,2))
else:
    print("...Please enter correct choice...")     

VIDEO LINK : -


No comments:

Post a Comment

Note: only a member of this blog may post a comment.