Question: in python: how fix the code below so that the output will print out on decimal place? the rounding should be at the print area.

in python: how fix the code below so that the output will print out on decimal place? the rounding should be at the print area.

class Rectangle: """ Rectangle class """ def __init__(self, width=1, height=2): """ Constructor """ # Initializing private variables self.__width = width; self.__height = height; def getWidth(self): """ Function that returns width of a rectangle """ return self.__width; def getHeight(self): """ Function that returns height of a rectangle """ return self.__height; def getArea(self): """ Function that returns area of a rectangle """ return self.__width * self.__height; def getPerimeter(self): """ Function that returns perimeter of a rectangle """ return 2 * (self.__width + self.__height);

def main(): """ Main function """ # Creating object rect = Rectangle(4, 40); # Printing data print(" A " + str(rect.getWidth()) + " x " + str(rect.getHeight()) + " rectangle has an area of " + str(rect.getArea()) + " and a perimeter of " + str(rect.getPerimeter()) + ". "); # Creating object rect1 = Rectangle(3.5, 35.7); # Printing data print(" A " + str(rect1.getWidth()) + " x " + str(rect1.getHeight()) + " rectangle has an area of " + str(rect1.getArea()) + " and a perimeter of " + str(rect1.getPerimeter()) + ". ");

# Calling main function main();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!