![]() |
Unit 18: Procedural Programming Assignment (Shop Simulation) - 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 Assignment (Shop Simulation) (/thread-6992.html) |
RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - Terafy - Dec-17-2017 I mean the that part of the code dose nothing unless it been called to run. RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - shaheduk323 - Dec-17-2017 so how do i call it RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - Terafy - Dec-17-2017 This is your function def newbalances(initialbalance, productname, advertisingcost): newbalance = initialbalance - advertisingcost - ptoductname * wholesaleprice return newbalanceNow to call it you need to assign it a variable (let call it todayBalance) and give it 3 arguments. todayBalance=newbalances(0, 'Nick', 100)I think wholesaleprice is a global variable... RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - shaheduk323 - Dec-17-2017 yes wholesale price is global RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - Terafy - Dec-17-2017 I dont get why productname is part of the equation. Anyway change 'Nick' to a number. Doing this on a phone is hard. And you variable ptoductname need changing RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - shaheduk323 - Dec-17-2017 (Dec-17-2017, 02:59 PM)Terafy Wrote: This is your function where should i put this part of the code RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - Terafy - Dec-17-2017 Anywhere below the functions you defined RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - shaheduk323 - Dec-17-2017 I give up. i had enough of the coding and whatever i define its the same error. my deadline is 11:55pm tonight and so i am too late just thought to tell you. the error kept on coming up even if i tried to define it. RE: Unit 18: Procedural Programming Assignment (Shop Simulation) - Terafy - Dec-17-2017 no dont give up! it was 1 am since my last post! In a new script paste this code. def newbalances(initialbalance, productname, advertisingcost): wholesaleprice = 9 newbalance = initialbalance - advertisingcost - productname * wholesaleprice return newbalance #calling the function newbalances #need input arguments (initialbalance, productname, advertisingcost) #and a variable to store it todayBalance=newbalances(1000, 10, 100) print(todayBalance) If you ran that code you would get:
|