Question: Part 1 : Define the Rectangle Class ( 2 marks ) Define a class named Rectangle. The class should have two private attributes: width and
Part : Define the Rectangle Class marks Define a class named Rectangle. The class should have two private attributes: width and height both default to Include the following methods: init self width: float, height: float Constructor to Part : Part :initialize the width and height.get widthself float Returns the width.get heightself float Returns the height.set widthself width: float Sets a new width should vali date that the width is positiveset heightself height: float Sets a new height should validate that the height is positivecalculate areaself float Returns the area of the rectan gle width times heightcalculate perimeterself float Returns the perimeter of the rectangle times width heightDefine the Circle Class marks Define a class named Circle. The class should have one private attribute: radius default to Include the following methods:init self radius: float Constructor to initialize the ra dius.get radiusself float Returns the radius.set radiusself radius: float Sets a new radius shouldvalidate that the radius is positivecalculate areaself float Returns the area of the circletimes radiuscalculate circumferenceself float Returns the circumference of the circle times times radiusInstantiating and Testing the Classes marks Create an instance of the Rectangle class and set the width to and the height to Create an instance of the Circle class and set the radius to Print the following details: The width, height, area, and perimeter of the rectangle. The radius, area, and circumference of the circlePart : Handling Invalid Input mark Modify the set width, set height, and set radius methods to raise a ValueError if a negative or zero value is passed.Expected OutputYour program should produce output similar to the following:Rectangle width: Rectangle height: Area: Perimeter: Circle radius: Area: Circumference:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
