![]() |
Unit 18 Procedural Programming Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Unit 18 Procedural Programming Python (/thread-7122.html) |
Unit 18 Procedural Programming Python - kanwal121 - Dec-21-2017 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 = 10 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 addvertcost £")) #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 product purchased>0 sales = random*advertisingCost productPurchased sold = 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)
RE: Unit 18 Procedural Programming Python - micseydel - Dec-21-2017 On line 76 you have an extra colon. Remove the first one on the line. How are you running your code? Any decent way of running it should tell you exactly what line, and often at what character on that line, the problem is occurring. RE: Unit 18 Procedural Programming Python - kanwal121 - Dec-21-2017 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)
RE: Unit 18 Procedural Programming Python - micseydel - Dec-21-2017 You need parenthesis to call the function. What you're trying to do is multiply a function by an int. You want to multiply the result of the function call with an int. random.randint -> random.randint()
RE: Unit 18 Procedural Programming Python - Terafy - Dec-21-2017 1) You are going to have a infinite loop. Need to move days = days - 1 inside the while loop.2) .randint need to have input argument as well. .randint(a, b)
|