Python Forum
Unit 18: Procedural Programming Assignment (Shop Simulation)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unit 18: Procedural Programming Assignment (Shop Simulation)
#21
I mean the that part of the code dose nothing unless it been called to run.
When my code doesn't work I don't know why **think** and when my code works I don't know why **think**
Reply
#22
so how do i call it
Reply
#23
This is your function
def newbalances(initialbalance, productname, advertisingcost):
    newbalance = initialbalance - advertisingcost - ptoductname * wholesaleprice
    return newbalance
Now 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...
When my code doesn't work I don't know why **think** and when my code works I don't know why **think**
Reply
#24
yes wholesale price is global
Reply
#25
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
When my code doesn't work I don't know why **think** and when my code works I don't know why **think**
Reply
#26
(Dec-17-2017, 02:59 PM)Terafy Wrote: This is your function
def newbalances(initialbalance, productname, advertisingcost):
    newbalance = initialbalance - advertisingcost - ptoductname * wholesaleprice
    return newbalance
Now to call it you need to assign it a variable (let call it todayBalance) and give it 3 arguments.

todayBalance=newbalances(0, 'Nick', 100)

where should i put this part of the code
Reply
#27
Anywhere below the functions you defined
When my code doesn't work I don't know why **think** and when my code works I don't know why **think**
Reply
#28
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.
Reply
#29
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:
Output:
810
When my code doesn't work I don't know why **think** and when my code works I don't know why **think**
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Homework Python unit test Paragoon2 4 1,476 Dec-12-2022, 12:45 PM
Last Post: Paragoon2
  Simulation DaRTHYGT 2 2,679 Jan-27-2020, 10:09 PM
Last Post: micseydel
  Help with Unit Tests pdub787 3 3,010 Nov-20-2019, 07:45 PM
Last Post: ndc85430
  Verilog HDL Programming to Python Programming? noobcoder 1 2,985 Jul-18-2019, 09:28 PM
Last Post: nilamo
  Help for my assignment - Object Oriented Programming denizkb 5 5,026 Jan-05-2019, 06:43 PM
Last Post: stullis
  Unit 18 Procedural Programming Python kanwal121 4 3,890 Dec-21-2017, 10:53 PM
Last Post: Terafy
  unit 18 codes Miss_Kaur 7 4,972 Dec-19-2017, 02:49 PM
Last Post: sparkz_alot
  Unit 18 Procedural Programming Python kanwal121 6 3,996 Dec-17-2017, 07:18 PM
Last Post: Terafy
  programming assignment mario 2 3,412 Dec-16-2017, 06:28 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020