Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how to fix the code that will round the output to two decimal place. the code is

ID: 3792826 • Letter: H

Question

how to fix the code that will round the output to two decimal place. the code is in python

#main method
def main():
#reading height and width from user
height = float(input("Enter the rectangle height: "))
width = float(input("Enter the rectangle width: "))
#displaying area and perimter
print("Rectangle area is "+str(getArea(height, width)))
print("Rectangle perimeter is "+str(getPerimeter(height, width)))
#rectangle area
def getArea(height, width):
return height * width;
#rectangle perimeter
def getPerimeter(height, width):
return 2 * (height + width);

main();

Explanation / Answer

#main method
def main():

#reading height and width from user
height = float(input("Enter the rectangle height: "))
width = float(input("Enter the rectangle width: "))

#displaying area and perimter
print("Rectangle area is "+str(getArea(height, width)))
print("Rectangle perimeter is "+str(getPerimeter(height, width)))

#rectangle area
def getArea(height, width):
Area=height * width;
#converting float to decimal
Area1=Decimal(Area)
return Area1;

#rectangle perimeter
def getPerimeter(height, width):
perimeter=2 * (height + width);
#rounding the decimal value to 2 places
perimeter1=round(perimeter,2)
return perimeter1;
main();