Page 1 of 1

1. Class Implementationa) Implement a class Rectangle with two attributes, width and height. b) Implement an init method

Posted: Sun May 15, 2022 1:53 pm
by answerhappygod
1. Class Implementationa) Implement a class Rectangle with two attributes, width and height. b) Implement an init method with an optional parameter type.Set the default value of the attributes of width and height to 1.c) Implement a display method to print the values of width and height.d) Instantiate two objects of type rectangle, one with arguments one without. r1 = Rectangle(4, 5) r2 = Rectangle()e) Call display() to print width and height.f) Access and print the attribute values of r1 and r2.
1. Class Implementation
a) Implement a class Rectangle with two attributes, width and height.
b) Implement an init method with an optional parameter type.
Set the default value of the attributes of width and height to 1.
c) Implement a display method to print the values of width and height.
d) Instantiate two objects of type rectangle, one with arguments one without.
r1 = Rectangle(4, 5)
r2 = Rectangle()
e) Call display() to print width and height.
f) Access and print the attribute values of r1 and r2.
1 Class Implementationa Implement A Class Rectangle With Two Attributes Width And Height B Implement An Init Method 1
1 Class Implementationa Implement A Class Rectangle With Two Attributes Width And Height B Implement An Init Method 1 (34.1 KiB) Viewed 111 times
In Python Please and Thank you.
1. Class Implementation a) Implement a class Rectangle with two attributes, width and height. b) Implement an init method with an optional parameter type. Set the default value of the attributes of width and height to 1. c) Implement a display method to print the values of width and height. d) Instantiate two objects of type rectangle, one with arguments one without. rl = Rectangle (4, 5) r2 = Rectangle() e) Call display() to print width and height f) Access and print the attribute values of rl and r2. Example Output Width: 4 Height: 5 Width: 1 Height: 1 Width of ri and r2: 4 & 1 Height of rl and r2: 5 & 1