0% found this document useful (0 votes)
3 views

sap

The document provides a Python script that calculates the perimeter and area of trapezoids and parallelograms based on user inputs. It prompts the user to enter the shape type and relevant dimensions, then computes and displays the results. The script includes a loop for repeated calculations until the user decides to exit.

Uploaded by

puteri anis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

sap

The document provides a Python script that calculates the perimeter and area of trapezoids and parallelograms based on user inputs. It prompts the user to enter the shape type and relevant dimensions, then computes and displays the results. The script includes a loop for repeated calculations until the user decides to exit.

Uploaded by

puteri anis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

shape =(input("Enter shape 'TRAPEZOID / PARALLELOGRAM:"))

while (shape == "TRAPEZOID"):


a = eval(input("Enter a:"))
b = eval(input("Enter b:"))
c = eval(input("Enter c:"))
d = eval(input("Enter d:"))
h = eval(input("Enter h:"))
perimeterTrapezoid = a + b + c + d
areaTrapezoid = ((a + b) * h)/2
print ("Perimeter of trapezoid is:", perimeterTrapezoid)
print ("Area of trapezoid is:", areaTrapezoid)
choice = input("Enter your choice PARALLELOGRAM or Q to exit:").upper()

else:
b = eval(input("Enter b:"))
c = eval(input("Enter c:"))
h = eval(input("Enter h:"))
perimeterParallelogram = b + b + c + c
areaParallelogram = b * h
print ("Perimeter of parallelogram is:", perimeterParallelogram )
print ("Area of parallelogram is:", areaParallelogram )

second try

shape =(input("Enter shape 'Trapezoid / Parallelogram' to start or 'Exit' to end


program:"))
while shape != EXIT:
if (shape == "Trapezoid"):
a = eval(input("Enter a:"))
b = eval(input("Enter b:"))
c = eval(input("Enter c:"))
d = eval(input("Enter d:"))
h = eval(input("Enter h:"))
perimeterTrapezoid = a + b + c + d
areaTrapezoid = ((a + b) * h)/2
print ("Perimeter of trapezoid is:", perimeterTrapezoid)
print ("Area of trapezoid is:", areaTrapezoid)
else :
shape =(input("Enter shape 'Trapezoid / Parallelogram' to start or 'Exit' to
end program:"))
x = shape.upper()
b = eval(input("Enter b:"))
c = eval(input("Enter c:"))
h = eval(input("Enter h:"))
perimeterParallelogram = b + b + c + c
areaParallelogram = b * h
print ("Perimeter of parallelogram is:", perimeterParallelogram )
print ("Area of parallelogram is:", areaParallelogram )

You might also like