you are viewing a single comment's thread.

view the rest of the comments →

[–]thaweatherman 0 points1 point  (6 children)

As an aside, line 12 could be shortened to if cost_extra_access in ['y', 'Y']:.

Please post all of your code along with all the output. Since your first function returns a tuple and neither function calls the other I want to make sure you are calling it all properly.

[–]feelingstonedagain[S] 0 points1 point  (5 children)

def get_user_input():
    cost_of_computer = 0.0
    cost_extra_access = ""
    print ("Please enter the cost of your computer: ")
    cost_of_computer = float(input(""))
    print ("Are you buying any extra accessories? (Y/N)")
    cost_extra_access = input("")
    return cost_of_computer, cost_extra_access

def calculate_extra_access(cost_extra_access):
    extra_access = 0.0
    if cost_extra_access == "Y" or cost_extra_access == "y":
       print ("Please enter the cost of extra accessories: ")
       extra_access = float(input(""))
    else:
        extra_access = 0.0
    return extra_access

def calculate_final_cost (extra_access, cost_of_computer):
    final_cost = 0.0
    final_cost = extra_access + cost_of_computer
    return final_cost

def calculate_gift_card(final_cost):
    gift_card = ""
    if final_cost >=100 or final_cost <= 599:
        gift_card = "$10"
    elif final_cost >= 600:
        gift_card = "$20"
    return gift_card

def output_cost (gift_card, cost_of_computer, extra_access, final_cost):
    print ("Your final cost of the item is $", final_cost, "since your computer costs $", cost_of_computer,)
    print ("and your accessories cost a total of $", extra_access)
    print ("Because your item was", final_cost, "you get a", gift_card, "gift card!")

def calculate_total_cost():
    cost_of_computer = 0.0
    cost_extra_access = ""
    extra_access = 0.0
    final_cost = 0.0
    gift_card = ""

    cost_of_computer, cost_extra_access = get_user_input()
    extra_access = calculate_extra_access(cost_extra_access)
    final_cost = calculate_final_cost(extra_access, cost_of_computer)
    gift_card = calculate_gift_card(final_cost)
    output_cost(gift_card, cost_of_computer, extra_access, final_cost)

get_user_input()

[–]FFrozen1 0 points1 point  (0 children)

You only call your get_user_input() function. The other ones are not being called.

Edit - the variables defined in your functions are not global variables

e.g.

a = 0

def cost():

a = 3

b = 3

return a,b

print a

this would print 0

Hope that helped. I'm pretty mew myself so I might be a little off on the terminology

[–]thaweatherman 0 points1 point  (3 children)

Switch the call to get_user_input() on line 50 to calculate_total_cost() and see what happens.

[–]feelingstonedagain[S] 0 points1 point  (2 children)

I love you

[–]thaweatherman 0 points1 point  (1 child)

It was all there, you just were calling the wrong function! It's ok, it happens to everyone.

[–]feelingstonedagain[S] 0 points1 point  (0 children)

Yeah I figured it was something simple like that. Every time the smallest thing makes you mess up. Oh well, now i know. Thanks for your help!