Advertisement
Poganu

Untitled

Jun 23rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. ''' Design a class named Stock to represent a company's stock.
  2.    It contains:
  3.    symbol
  4.    name
  5.    previousClosingPrice
  6.    currentPrice
  7.  
  8.    '''
  9.  
  10. class Stock:
  11.     def __init__(self, a, b, c, d):
  12.         self.symbol = a
  13.         self.name = b
  14.         self.previousClosingPrice = c
  15.         self.currentPrice = d
  16.  
  17.     def getStockName(self):
  18.         return self.name
  19.  
  20.     def getStockSymbol(self):
  21.         return self.symbol
  22.  
  23.     def seteazaStocAnterior(self, stockAnterior):
  24.         self.previousClosingPrice = stockAnterior
  25.  
  26.     def veziStocAnterior(self):
  27.         return self.previousClosingPrice
  28.  
  29.     def seteazaPretCurent(self, pretCurent):
  30.         self.currentPrice = pretCurent
  31.  
  32.     def veziPretCurent(self):
  33.         return self.currentPrice
  34.  
  35.     def getChangeProcent(self):
  36.         return self.previousClosingPrice / self.currentPrice * 100
  37.  
  38.  
  39. IntelCorporation = Stock("INTC", "Intel Corporation", 20.5, 20.35)
  40.  
  41. print(IntelCorporation.getChangeProcent())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement