Skip to main content

Posts

Showing posts from May, 2020
#Object Oriented Programming  (Python) #SIMPLE PROFIT CALCULATOR   --  StudySourceCodes.blogspot.com class Sales: def __init__(self, prodName,costPrice,sellingPrice): self.prodName = prodName self.costPrice = costPrice self.sellingPrice = sellingPrice #Getting coat price def get_costPrice(self): return self.costPrice #Getting selling price def get_sellingPrice(self): return self.sellingPrice class Product: def __init__(self,prodCat,max_prods): self.prodCat = prodCat self.max_prods = max_prods self.products = [] #Adding products to a list def add_prods(self,product): if len(self.products) < self.max_prods: self.products.append(product) print("Product successfully added!\n\n") else: print("Oops! This product has reached maximum number of products!") #Calculating total profit def get_tot_profit(self): tot_profit = 0 for product in self.products: profit = product.get_sellingPri