Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i am new to pyton and using pyton 3 on mac i need help doing this, i need to kno

ID: 3829900 • Letter: I

Question

i am new to pyton and using pyton 3 on mac i need help doing this, i need to know how to make it

Sections 7.2-7.3 7.1 (The Rectangle class) Following the example of the Circle class in Section 7.2, design a class named Rectangle t represent a rectangle. The class contains: Two data fields named width and height L 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. L A method named getArea C) that returns the area of this rectangle. L A method named rimeter C that returns the perimeter. Draw the UML diagram for the class, and then implement the class. Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.7. Display the width, height, area, and perimeter of each rectangle in this order. Sections 7.4-7.7 7.2 (The Stock class) Design a class named Stock to represent a company's stock that contains A private string data field named symbol for the stock's symbol. A private string data field named name for the stock's name. A private float data field named previousclosingPrice that stores the stock price for the previous day. A private float data field named currentPrice that stores the stock price for the current time. A constructor that creates a stock with the specified symbol, name, previous price, and current price A et method for returning the stock name. A get method for returning the stock symbol. Get and set methods for getting/setting the stock's previous price. Get and set methods for getting/setting the stock's current price. L A method named getChangePercent C that returns the percentage changed. from previous ClosingPrice to current Price Draw the UML iagram for the class, and then implement the class. Write a test program that creates a Stock object with the stock symbol INTC, the name Intel

Explanation / Answer

7.1

class Rectangle:
def __init__(self, width, height):
self.height = height
self.width = width
def getArea(self):
return self.height * self.width
  
def getPerimeter(self):
return (self.height + self.width)*2

def main():
height = float(input("Enter height: "))
width = float(input("Enter width: "))
rect = Rectangle(width, height)
print("Area: " + str(rect.getArea()))
print("Perimeter: " + str(rect.getPerimeter()))

if __name__ == '__main__':
main()

# code link: https://paste.ee/p/h6s3Y