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>It would appear that you wanted to pass in some parameters to your method. </p>

<p>If that is the case, you need to move the "calculate" and "get" functions.</p>

<p>And, no need to re-prompt for input - you already have parameters</p>

<pre><code>def calculate_price(wood_type, drawers):
    # wood_type = get_wood_type()
    # drawers = get_drawers()
    wood_price = 0
    drawer_price = 0

    # ... other calulations

    return drawer_price + wood_price

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

    ### Either do this here, or pass in via the main method below
    # 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 ", wood, ". The total for that was ", drawer_count * 30 - price, ".")
    print("Your total is: ", price)

if __name__ == '__main__':

    wood = get_wood_type()
    drawer_count = get_drawers()

    display_price(wood, drawer_count)
</code></pre>

python python-3.x price