Skip to content

Instantly share code, notes, and snippets.

@jerryalfs
Created January 31, 2016 09:39
Show Gist options
  • Save jerryalfs/f922afb42945d1c5f320 to your computer and use it in GitHub Desktop.
Save jerryalfs/f922afb42945d1c5f320 to your computer and use it in GitHub Desktop.
Calculate Area Of Trapezoid With Python
#Area Of A Trapezoid
h = input("Enter the height of the trapezoid : ")
#input value height of the trapezoid
h = float(h)
#convert h into float value
lb = input("Enter the lenght of the bottom base : ")
#input value lenght bottom base
lb = float(lb)
#convert lenght bottom base to float value
lt = input("Enter the lenght of the top base : ")
#input value lenght top base
lt = float(lt)
#convert lenght top base to float value
a = 1/2 * (lb + lt) * h
#formula to calculate area of trapezoid
print ("Area of a trapezoid : ",a)
#print value area of a trapezoid have stored with a variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment