what is parallelogram ? :
A four-sided plane rectilinear figure with opposite sides parallel.
Types of parallelogram :
- Rectangle
- Rhombus
- Square
Formula to calculate perimeter of parallelogram :
The perimeter is the sum of the length of all the 4 sides. The perimeter of a parallelogram is the total distance outside the geometrical shape. The opposite sides of a parallelogram are equal and so the perimeter becomes twice the sum of two parallel sides say a and b.
Perimeter= 2 (a + b) units
Python program to calculate the perimeter of a parallelogram :
l =float(input("Enter base/length of the parallelogram : "))
w =float(input("Enter width of the parallelogram : "))
perimeter = 2*(l+w)
print("The perimeter of given parallelogram is : ", perimeter)
Output :
Explanation of above code:
l =float(input("Enter base/length of the parallelogram : "))
w =float(input("Enter width of the parallelogram : "))
Here, l and w is variable that store a decimal value in which l store the value of base/lenght of the parallelogram and w store the value of width of the parallelogram.
perimeter=2*(l+w)
then, perimeter (variable ) store an expression (formula) that store the perimeter of a parallelogram.
print("The perimeter of given parallelogram is : ", perimeter)
At last we print the perimeter of the parallelogram.
User tasks :
How to calculate area of parallelogram in python ?
0 Comments