use UML graphical notations to describe classes and objects.
use UML graphical notations to describe classes and objects.
1.)
class Investment:
def __init__(self,p,i,n):
self.p=p
self.i=i
self.n=n
def value_after(self):
return ((self.p*(1+self.i))**self.n)
def __str__(self):
print('Principal-$:',self.p, 'Interest rate:',self.i,'%','Interest-$:',a.value_after())
a=Investment(2000,6.32,5)
(a.__str__())
2.)
class Rectangle:
def __init__(self,w=1,h=2):
self.width = w;
self.height = h;
def getArea(self):
return self.width*self.height
def getPerimeter(self):
return 2*(self.width+self.height)
w = 4
print ("The width of the rectangle is "+str(w))
h = 40
print ("The height of the rectangle is "+str(h))
r = Rectangle(w,h);
print('The area of the rectangle is', r.getArea())
print('The perimeter of the rectangle is', r.getPerimeter())
w = 3.5
print("The width of the rectangle is "+str(w))
h = 35.7
print("The height of the rectangle is "+str(h))
r = Rectangle(w,h);
print("The area of the rectangle is", (r.getArea()))
print("The perimeter of the rectangle is", (r.getPerimeter()))
Step by step
Solved in 2 steps with 1 images