Write a program in python to read base,lenght ,width ,height of a parallelogram and calculate its area and
Answers
Answer:
b=float(input("Enter base of parallelogram:"))
w=float(input("Enter width of parallelogram:"))
l=float(input("Enter length of parallelogram:"))
h=float(input("Enter height of the parallelogram:"))
area=b*h
print("Area= ",area)
Explanation:
Here's a Python program that reads the base, length, width, and height of a parallelogram and calculates its area and perimeter:
python
# Read the base, length, width, and height of a parallelogram from the user
base = float(input("Enter the base of the parallelogram: "))
length = float(input("Enter the length of the parallelogram: "))
width = float(input("Enter the width of the parallelogram: "))
height = float(input("Enter the height of the parallelogram: "))
# Calculate the area of the parallelogram
area = base * height
# Calculate the perimeter of the parallelogram
perimeter = 2 * (length + width)
# Print the area and perimeter of the parallelogram
print("The area of the parallelogram is:", area)
print("The perimeter of the parallelogram is:", perimeter)
In this program, we first read the base, length, width, and height of the parallelogram from the user using the input() function.
We convert the user input to float values using the float() function.
Next, we calculate the area of the parallelogram using the formula base * height, where base is the length of the base of the parallelogram and height is the height of the parallelogram.
We store the result in the variable area.
Finally, we calculate the perimeter of the parallelogram using the formula 2 * (length + width), where length is the length of one of the sides of the parallelogram and width is the width of the parallelogram.
We store the result in the variable perimeter.
We then use the print() function to display the area and perimeter of the parallelogram to the user.
For similar question on program in python.
https://brainly.in/question/49222417
#SPJ3