1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reika [66]
3 years ago
10

Create a geometry application For this exercise you will create a module named ‘shapes.py’ and a program that uses it. The modul

e will contain two classes: Circle and Rectangle. • Start with the class example (Module 10, part 1b) as a basis for Circle o Add an attribute and getter method for the perimeter (distance around the outside, officially called the circumference ). • Write a class named Rectangle to represent a rectangle. The class should contain: o Two attributes that specify the length and the width. These should initially be set when the object is created with __init__. o Setter and getter methods for length and width. o Attributes and getter methods for the area and the perimeter. Then write a main program that will use the module.
Computers and Technology
1 answer:
Maurinko [17]3 years ago
7 0

Answer:

See explaination

Explanation:

# shapes.py

import math class Circle: def __init__(self, radius = 0): self.__radius = radius self.__area = math.pi * self.__radius ** 2 self.__circumference = 2 * math.pi * self.__radius def set_radius(self, radius): self.__radius = radius self.__area = math.pi * self.__radius ** 2 self.__circumference = 2 * math.pi * self.__radius def get_radius(self): return self.__radius def get_area(self): return self.__area def get_circumference(self): return self.__circumference class Rectangle: def __init__(self, length = 0, breadth = 0): self.__length = length self.__breadth = breadth self.__calc_area() self.__calc_perimeter() def __calc_area(self): self.__area = self.__length * self.__breadth def __calc_perimeter(self): self.__perimeter = 2 * (self.__length + self.__breadth) def set_length(self, length): self.__length = length self.__calc_area() self.__calc_perimeter() def set_breadth(self, breadth): self.__breadth = breadth self.__calc_area() self.__calc_perimeter() def get_length(self): return self.__length def get_breadth(self): return self.__breadth def get_area(self): return self.__area def get_perimeter(self): return self.__perimeter

# testShapes.py (Main program)

import shapes if __name__ == "__main__": print("a. Circle") print("b. Rectangle") choice = input("\nChoose a Shape to continue: ") if choice == "a": radius = int(input("\nEnter Radius of the Circle: ")) myCircle = shapes.Circle(radius) print("\nArea of Circle:", myCircle.get_area()) print("Circumference of Circle:", myCircle.get_circumference()) reset = input("Do you want to change Radius (y/n): ") if reset == "y" or reset == "Y": radius = int(input("\nEnter new Radius of the Circle: ")) myCircle = shapes.Circle(radius) print("\nArea of Circle:", myCircle.get_area()) print("Circumference of Circle:", myCircle.get_circumference()) elif choice == "b": length = int(input("\nEnter length of Rectangle: ")) breadth = int(input("Enter breadth of Rectangle: ")) myRectangle = shapes.Rectangle(length, breadth) print("\nArea of Rectangle:", myRectangle.get_area()) print("Perimeter of Rectangle:", myRectangle.get_perimeter()) reset = input("Do you want to change Length and Breadth (y/n): ") if reset == "y" or reset == "Y": length = int(input("\nEnter new length of Rectangle: ")) breadth = int(input("Enter new breadth of Rectangle: ")) myRectangle = shapes.Rectangle(length, breadth) print("\nArea of Rectangle:", myRectangle.get_area()) print("Perimeter of Rectangle:", myRectangle.get_perimeter()) else: print("Invalid choice!!! \'", choice, "\'\nExiting...")

You might be interested in
Steve is happy today but he ____ yesterday​
suter [353]

steve is happy today but he wasn't yesterday

3 0
2 years ago
Read 2 more answers
Suppose you are asked to design a rotating disk where the number of bits per track is constant. You know that the number of bits
Olenka [21]

Answer:

suppose i was i would tell them i dont know and walk away

Explanation:

in thoery this is correct

you said suppose so i answerd

there is no use in reporting or getting this taken down

nether is it right

im not stealing points

Because in thoery its an answer

<em><u>THIS IS MY PROTEST</u></em>

6 0
3 years ago
Which body of water is most likely to be a marine ecosystem?
Sophie [7]

Answer:

The body of water that is most likely to be a marine ecosystem would be an estuary.

Explanation:

An estuary is a widened, often funnel-shaped mouth of a river, where fresh river water and salt sea water are mixed and thus brackish water is created, and where tidal differences can be observed. When a river flows as a system of branches, it is called a delta.

Estuaries often have a great natural value. They typically consist of swallows and salt marshes that are very rich in invertebrates and thus have a great attraction for birds, among other things.

4 0
3 years ago
IPv4 address are of how many types?<br>​
Butoxors [25]

Answer: four different types

There are four different types of IPv4 addresses: public, private, static, and dynamic. While the public and private are indicative of the location of the network—private being used inside a network while the public is used outside of a network—static and dynamic indicate permanency.

7 0
3 years ago
Which of the following detects unauthorized user activities, attacks, and network compromises, alerts of the detected attacks, a
Anit [1.1K]

The answer is IPS (Intrusion Prevention Systems)

The Intrusion Prevention Systems and Intrusion Detection Systems (IDS) are two security technologies that secure networks and are very similar in how they work. The IDS detects unauthorized user activities, attacks, and network compromises, and also alerts. The IPS, on the other hand, as mentioned, is very similar to the IDS, except that in addition to detecting and alerting, it can also takes action to prevent breaches.


3 0
3 years ago
Other questions:
  • What is the IEEE standard for the Wi-Fi Protected Access 2 (WPA2) security protocol?
    6·1 answer
  • When creating a professional presentation, how many typefaces are recommended at the most?
    5·1 answer
  • The inability of BAE Automated Systems to create an automated baggage handling system led to a significant delay in the opening
    10·1 answer
  • A network technician is tasked with designing a firewall to improve security for an existing FTP server that is on the company n
    9·1 answer
  • In python,_______ are used to define the conditions necessary for a while loop to run.
    7·2 answers
  • Give an example of a language L such that |L|=5 and |L^2|=16.
    5·1 answer
  • A member function of a derived class may not have the same name as a member function of a base class
    9·1 answer
  • When using linear or reciprocal navigation, what should be the interface include?
    15·1 answer
  • Ian kno da answer tell me
    7·2 answers
  • What the difference between an operating system drive and a storage drive?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!