Desk Price Calculation in Python
<p>I have a little exercise I need to do in Python that's called "Desk Price Calculation". There need to be 4 functions which are used in the program. </p>

<p>My main problem is using the output of a function in another function.</p>

<pre><code>def get_drawers():
    drawers = int(input('How many goddamn drawers would you like? '))
    return drawers

def get_wood_type():
    print('The types of wood available are Pine, Mahogany or Oak. For any other wood, type Other')
    wood = str(input('What type of wood would you like? '))
    return wood

def calculate_price(wood_type, drawers):
    wood_type = get_wood_type()
    drawers = get_drawers()
    wood_price = 0
    drawer_price = 0

    #wood price
    if wood_type == "Pine":
        wood_price = 100
    elif wood_type == "Oak":
        wood_price = 140
    elif wood_type == "Mahogany":
        wood_price = 180
    else:
        wood_price = 180

    #price of drawers
    drawer_price = drawers * 30

    return drawer_price + wood_price

def display_price(price, wood, drawer_count):
    price = calculate_price()
    wood = get_wood_type()
    drawer_count = get_drawers()

    print("The amount of drawers you requested were: ", drawer_count, ". Their total was ", drawer_count * 30, ".")
    print("The type of would you requested was ", get_wood_type(), ". The total for that was ", drawer_count * 30 - calculate_price(), ".")
    print("Your total is: ", price)

if __name__ == '__main__':

    display_price()
</code></pre>

<p>I guess you get an error like this (that should have been added to your question by the way) :</p>

<pre><code>Traceback (most recent call last):
  File "test.py", line 42, in &lt;module&gt;
    display_price()
TypeError: display_price() missing 3 required positional arguments: 'price', 'wood', and 'drawer_count'
</code></pre>

<p>You defined your <code>display_price()</code> function like this :</p>

<pre><code>def display_price(price, wood, drawer_count):
</code></pre>

<p>So it expects 3 arguments when you call it, but you call it without any.</p>

<p>You have to either :</p>

<ol>
<li>redefine your function without argument (that would be the most logical solution since <code>price</code>, <code>wood</code> and <code>drawer_count</code> are defined in its scope.</li>
<li>pass these arguments to the call of this function, but that would be useless for the reason I mentionned in <strong>1</strong>. Unless you remove these arguments definition.</li>
</ol>

<p><strong>PS:</strong> You'll have the same problem with <code>calculate_price()</code> since it expects two arguments, but you pass none to it.</p>

<h2>About function's arguments :</h2>

<p>When you define a function, you also define the arguments it expects when you call it.</p>

<p>For instance, if you define :</p>

<pre><code>def f(foo):
    # Do some stuff
</code></pre>

<p>a correct <code>f</code> call would be <code>f(some_val)</code> and not <code>f()</code></p>

<p>Plus it would be useless to define <code>f</code> like this :</p>

<pre><code>def f(foo):
    foo = someval
    # Do some other stuff
</code></pre>

<p>since foo is direcly redefined in the function's scope without even using the initial value.</p>

<p>This will help you to discover functions basics :</p>

<p><a href="http://www.tutorialspoint.com/python/python_functions.htm" rel="nofollow">http://www.tutorialspoint.com/python/python_functions.htm</a></p>

python python-3.x price