SOLVE IN PYTHON: Exercise #1: Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods:
A private variable of type double named radius to represent the radius. Set to 1.
Constructor Methods:
Python : An overloaded constructor method to create a default circle.
C# & Java: Default Constructor with no arguments.
C# & Java: Constructor method that creates a circle with user-specified radius.
Method getRadius() that returns the radius.
Method setRadius() that sets the radius.
Method getArea() that returns the area.
Method getPerimeter() that returns the perimeter.
Method toString()to printout a meaningful description of the circle as follows:
The circle has radius X. Where X is the value of variable radius.
Now design and implement a test program to create a default circle object and test all class methods on the object. Print the object after each method call and use meaningful label for each method call as shown in the following sample run.
Sample run:
Print radius:
The radius is 1.
Print area:
The area is 3.14
Print perimeter:
The perimeter is 6.28
Set radius to 10 and print the object: The circle has radius 10.
Print area:
The area is 314.23
Print perimeter:
The perimeter is 62.81
import math
# circle class here
class Circle:
def __init__(self, radius=1):
self.radius = radius
def setRadius(self, radius):
self.radius = radius
def getRadius(self):
return self.radius
def getArea(self):
return math.pi * self.radius ** 2
def getPerimeter(self):
return 2 * math.pi * self.radius
def __str__(self):
return "The area is {:.2f}, The perimeter is {:.2f}".format(self.getArea(), self.getPerimeter())
# test program below
c = Circle()
print("The radius is " + str(c.getRadius()))
print(c)
c.setRadius(10)
print("The radius is " + str(c.getRadius()))
print(c)

SOLVE IN PYTHON: Exercise #1: Design and implement class Circle to represent a circle object. The...
Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods: 1. A private variable of type double named radius to represent the radius. Set to 1. 2. Constructor Methods: • Python : An overloaded constructor method to create a default circle. • C# & Java: Default Constructor with no arguments. • C# & Java: Constructor method that creates a circle with user-specified radius. 3. Method getRadius() that returns the radius. 4. ...
PLEASE DO BOTH OF THESE IN PYTHON 1) Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. A non-argument constructor method to create a default rectangle. Another constructor method to create a rectangle with user-specified height and width. Python...
NEEDS TO BE IN PYTHON: (The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: - Two data fields named width and height. - A constructor that creates a rectangle with the specified width and height. The default values are 1 and 2 for the width and height, respectively. - A method named getArea() that returns the area of this rectangle. - A method named...
PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: 1. Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. 2. A non-argument constructor method to create a default rectangle. 3. Another constructor method to...
SOLVE IN PYTHON: Exercise #2: Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods: Assume that the station and volume settings range from 1 to 10. A private variable of type int named station to represent a station number. Set to 1. A private variable of type int named volume to represent the volume setting. Set to 1. A private variable of type boolean named on to represent the radio...
PYTHON Exercise #2: Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods: Assume that the station and volume settings range from 1 to 10. 1. A private variable of type int named station to represent a station number. Set to 1. 2. A private variable of type int named volume to represent the volume setting. Set to 1. 3. A private variable of type boolean named on to represent the...
(The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: ■ Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ■ A no-arg constructor that creates a default rectangle. ■ A constructor that creates a rectangle with the specified width and height. ■ A method named getArea()...
JAVA design a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. design...
Following the example of the Circle class in Section 8.2, design a class named Rectangle to represent a rectangle. The class contains: ■ Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ■ A no-arg constructor that creates a default rectangle. ■ A constructor that creates a rectangle with the specified width and height. ■ A method named getArea() that returns the...
C++ 8. Circle Class Write a Circle class that has the following member variables: • radius: a double • pi: a double initialized with the value 3.14159 The class should have the following member functions: • Default Constructor. A default constructor that sets radius to 0.0. • Constructor. Accepts the radius of the circle as an argument. • setRadius. A mutator function for the radius variable. • getRadius. An accessor function for the radius variable. • getArea. Returns the area...