Dec-21-2017, 06:39 PM
import random #this is to import the random number for calculations initialBalance = 10000 #this is the initial balance £1000 wholeSalePrice = 40 #this is the wholesale price shopSalePrice = 80 #shops sells the product for £40 days = 0 #days end at 0 newBalance = 250 #procedures import random initialBalance = 10000 randomNumber = random.randint(1,50) def costs (wholeSalePrice,productPurchased): calculations = wholeSalePrice*productPurchased #this is to calculte the wholeslae price by the product purchased price print (calculations) return calculations def calcNewBalance (initialBalance,addvertCost,productPurchased): #this is to pass the calculations throgh the parameter answer = initialBalance-addvertCost-productPurchased*wholeSalePrice #this is to output the new balnace after deducting the advertising cost and the product purchased cost from the new balnace print (answer) return answer def calpriceOfProduct (amount): priceOfProduct = amount #this is to calculte the wholeslae price by the product purchased price print (priceOfProduct) return priceOfProduct def calshopPrice (amount): shopPrice = amount #this is to calculte the wholeslae price by the product purchased price print (shopPrice) return shopPrice def calculateSalesFigures(salesFigures): #this is to generate a number to calculate sales on a daily basis sales = random.randint(1,50) print (sales) return sales def expenses(everyDayExpenses): #this is to calculate the daily expenses WholeSalePrice = 40 stock = 20 dailyExpenses = WholeSalePrice*stock print (dailyExpenses) return dailyExpenses def balanceUpdate(newBalance,salesFigure,dailyExpenses): updatedBalance = (newBalance + salesFigure - dailyExpenses)#this is the remaining balance after the daily expenses print ("newbalance is £:" + str(updatedBalance)) print (updatedBalance) return updatedBalance #_________________________________________________________________________ #input print("initial balance is £" + str (initialBalance)) advertisingCost = int(input("please enter a value for advertingCost £")) #this inforamtion will be displayed for the user to insert the amount productPurchased = int (input ("please enter the amount of products you wish to purchase for stock £")) #this inforamtion will be displayed for the user to insert the amount expenses = int(input("Please enter how much you want to spend on expenses £")) priceOfProduct = int(input(" what is the price Of Product £")) shopPrice = int(input(" what is the shopPrice £")) sales = int(input(" what is the sales price £")) print ("") #_________________________________________________________________________ #process days = 30 randomNumber = random.randint(1,advertisingCost) days = days - 1 while (days >0) and (newBalance >0): if productPurchased>0: sales = (random.randint*advertisingCost) productSold = sales//shopPrice print ("days" + str (days)) #this is the while statement for the loop if (productSold>productSold): lackOfStock = productSold - productPurchased lostProfit = lackOfStock*shopPrice#this is a block of code for If statement showing working out for handling products sold and in stock sales = sales - lostProfit newBalance = newBalance-sales-expenses print ("newbalance is £:" + str(newBalance)) print ("") #_________________________________________________________________________ #output if (newBalance <0): print ("we need more stock") else: print("stock is fine") #this IF statement is to decide if the stock is okay or more stock is needed costs = (wholeSalePrice,productPurchased) #these are the variables set for procedures newBalance = calcNewBalance(newBalance,advertisingCost,productPurchased) salesFigure = calculateSalesFigures(0) updatedBalances = balanceUpdate(newBalance,salesFigure,expenses)
Error:initial balance is £10000
please enter a value for advertingCost £40
please enter the amount of products you wish to purchase for stock £20
Please enter how much you want to spend on expenses £20
what is the price Of Product £10
what is the shopPrice £15
what is the sales price £12
Traceback (most recent call last):
File "F:/Level 4/Kevin/Assignement_testing.py", line 78, in <module>
sales = (random.randint*advertisingCost)
TypeError: unsupported operand type(s) for *: 'method' and 'int'
>>>