Please help if you can!

Discussion in 'Python' started by bobflipperdoodle@gmail.com, Dec 26, 2012.

  1. Guest

    I really hope you can help!

    I need to create a program where the user can order any combination and quantity of 3 products. I then offer a 10% discount if the customer correctly answers a trivia question. After that, there are 3 choices for shipping.

    I have most of the program completed but I'm struggling with the most important parts :/ I can get the total with discount to calculate only if i order every item. I also cant figure out how to get the shipping calculated correctly, including where to put any code referring back to the trivia question. Can somebody please help me with this? I would really appreciate it!

    Here is the code:

    shop_again = 'y'

    print("Welcome to the Star Wars Shop!")
    customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
    while shop_again == 'y':
    if (customer == 2):
    print("Welcome to the Star Wars Memorabilia Shop!")
    customer = eval(input("Is there a customer in line? (1 = yes, 2= no)> "))

    elif (customer == 1):
    print("Please select an item to update your order and any other number to check out.")
    print("Yoda Figure: $10 each.")
    print("Star Wars Movie DVD: $20 each.")
    print("Death Star Lego Set: $200 each.")
    print(" 1 for Yoda Figure")
    print(" 2 for Star Wars Movie DVD")
    print(" 3 for Death Star Lego Set")
    order = eval(input("Order: "))


    if (order == 1):
    yoda = eval(input("How many Yoda Figures do you want? : "))
    yodatotal = 10 * yoda
    print("Total:", yodatotal)
    print("Current order:", yoda, "for", yodatotal)
    if (order == 2):
    movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
    movietotal = 20 * movie
    print("Total:", movietotal)
    print("Current order:", movie, "for", movietotal)
    if (order == 3):
    legos = eval(input("How many Death Star Lego Sets do you want? : "))
    legototal = 200 * legos
    print("Total:", legototal)
    print("Current order:", legos, "for", legototal)

    shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N'for no: ")
    print()
    print("Yoda Figures: ",yoda,"Totaling", yodatotal)
    print("Star Wars Movies: ", movie,"Totaling", movietotal)
    print("Death Star Legos: ", legos,"Totaling", legototal)
    itemstotal = yodatotal + movietotal + legototal
    print("Your order before shipping and discounts: ",itemstotal)
    print()
    print("Answer a trivia question for a discount!")
    discount = eval(input("On what planet did Yoda live when Luke Skywalker first met him? 1) Earth 2) Dagobah 3) Pluto :"))
    if (discount == 1):
    print("Sorry, that answer was wrong!")
    if (discount == 2):
    print("That's correct, you get a 10% discount!")
    if (discount == 3):
    print("Sorry, that answer was wrong!")
    print()
    if (discount == 1):
    total = itemstotal
    print("Your total before shipping: ",total)

    if (discount == 2):
    total = itemstotal * .9
    print("Your total before shipping: ",total)

    if (discount == 3):
    total = itemstotal
    print("Your total before shipping: ",total)


    print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) Express Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 business days, free.")
    shipping = eval(input("Please select the shipping method you want: "))

    if (shipping == 1):

    total == total % 50
    total == total * 5
    print("Your total is: ",total)
    if (shipping == 2):
    total == total/50
    total == total % 50
    total == total * 10
    print("Your total is: ",total)
    if(shipping == 3):
    print("Your total is: ",total)
    print()
    print("Thanks for shopping here! Please come again!")
     
    , Dec 26, 2012
    #1
    1. Advertising

  2. Dave Angel Guest

    On 12/26/2012 06:04 PM, wrote:
    > I really hope you can help!
    >


    Please use the existing thread when you're continuing to ask the same
    question.

    This mailing list has no way to delete messages.

    So what changes are there between the two versions of the code? Are
    they marked somehow?

    Have you absorbed and implemented the very useful comments made by
    Mitya? Whenever you find yourself doing exactly the same code many
    times, chances are high that you should factor it into a function, or a
    class.


    --

    DaveA
     
    Dave Angel, Dec 26, 2012
    #2
    1. Advertising

  3. Guest

    First, sorry for starting a new post - I didn't want anyone to have to readthrough the whole first one when the questions were completely different :/

    Second, I honestly have no idea how to answer your questions. I am a sophomore in high school and I am trying to learn this on my own because my teacher is not very good at explaining things.

    i just cant figure out how to get the total when an order is placed withoutthe customer ordering at least one of each item. I also can't figure out how to get the shipping to calculate correctly. It is an intro class and weare using just the basics. Most of what Mitya said is stuff I've never seen before, although I am very grateful for her response, I am supposed to use only what the teacher "taught".

    Sorry if I frustrated you. I'm just a kid trying to learn. Any help is appreciated


    On Wednesday, December 26, 2012 6:49:27 PM UTC-5, Dave Angel wrote:
    > On 12/26/2012 06:04 PM, wrote:
    >
    > > I really hope you can help!

    >
    > >

    >
    >
    >
    > Please use the existing thread when you're continuing to ask the same
    >
    > question.
    >
    >
    >
    > This mailing list has no way to delete messages.
    >
    >
    >
    > So what changes are there between the two versions of the code? Are
    >
    > they marked somehow?
    >
    >
    >
    > Have you absorbed and implemented the very useful comments made by
    >
    > Mitya? Whenever you find yourself doing exactly the same code many
    >
    > times, chances are high that you should factor it into a function, or a
    >
    > class.
    >
    >
    >
    >
    >
    > --
    >
    >
    >
    > DaveA
     
    , Dec 27, 2012
    #3
  4. Guest

    First, sorry for starting a new post - I didn't want anyone to have to readthrough the whole first one when the questions were completely different :/

    Second, I honestly have no idea how to answer your questions. I am a sophomore in high school and I am trying to learn this on my own because my teacher is not very good at explaining things.

    i just cant figure out how to get the total when an order is placed withoutthe customer ordering at least one of each item. I also can't figure out how to get the shipping to calculate correctly. It is an intro class and weare using just the basics. Most of what Mitya said is stuff I've never seen before, although I am very grateful for her response, I am supposed to use only what the teacher "taught".

    Sorry if I frustrated you. I'm just a kid trying to learn. Any help is appreciated


    On Wednesday, December 26, 2012 6:49:27 PM UTC-5, Dave Angel wrote:
    > On 12/26/2012 06:04 PM, wrote:
    >
    > > I really hope you can help!

    >
    > >

    >
    >
    >
    > Please use the existing thread when you're continuing to ask the same
    >
    > question.
    >
    >
    >
    > This mailing list has no way to delete messages.
    >
    >
    >
    > So what changes are there between the two versions of the code? Are
    >
    > they marked somehow?
    >
    >
    >
    > Have you absorbed and implemented the very useful comments made by
    >
    > Mitya? Whenever you find yourself doing exactly the same code many
    >
    > times, chances are high that you should factor it into a function, or a
    >
    > class.
    >
    >
    >
    >
    >
    > --
    >
    >
    >
    > DaveA
     
    , Dec 27, 2012
    #4
  5. Guest

    I cannot tell you how grateful I am that you took the time to do all of this. I have been working on it all day and you are a better teacher in a fewminutes than my teacher has been in 4 months. THANK YOU!

    And thank you again, Mitya. I really appreciate your time and effort too! Someday I'll be advanced enough to understand it lol

    I'm going to take a break and work on it more tomorrow. I'll be back.

    Thank you!


    On Wednesday, December 26, 2012 6:57:39 PM UTC-5, Joshua Landau wrote:
    > THIS IS A LONG POST, BUT IF YOU WANT TO LEARN YOU SHOULD READ IT. SERIOUSLY.
    >
    >
    > UNLIKE Mitya Sirenef's THIS DOES NOT ASSUME MORE KNOWLEDGE THAN IS IN YOUR POST ALREADY, ALTHOUGH HIS IS DEFINITELY BETTER OVERALL. AS SUCH, THERE ARE NO FUNCTIONS.
    >
    >
    >
    > OK. There are several small errors in here, but there's nothing too largeor worth much worry.
    >
    >
    >
    > On 26 December 2012 21:40, <> wrote:
    >
    >
    > I really hope you can help!
    >
    > I need to create a program where the user can order any combination and quantity of 3 products. I then offer a 10% discount if the customer correctly answers a trivia question.  After that, there are 3 choices for shipping.
    >
    >
    >
    > I have most of the program completed but I'm struggling with the most important parts :/  I get the total of multiple orders of the same item, butwe can't figure out how to total the entire order - before discounts and shipping - and then where to put any code referring back to the trivia question. Can somebody please help me with this? I would really appreciate it!
    >
    >
    >
    >
    >
    > You write that you "need" to do this, which may hint that this is some sort of homework. If so, it's generally a nice thing to say as much. That said, as long as you've given a good shot at it it's normally fine.
    >
    >
    >  This is the code:
    >
    >
    >
    >
    >
    > My *very first* thought about this code is that it's really badly spaced.Don't put lines together so much! [https://gist.github.com/4383950] shows how much nicer things look when they're partitioned more. You may not agree, but it took about 10 seconds and I prefer it.
    >
    >
    >  shop_again = 'y'
    >
    >
    >
    >
    >
    > Hold on! Hold on!
    > shop_again should have a True/False value. It is screaming to be a boolean. "y" is a letter, not a boolean. Thus:
    >
    >
    > shop_again = True
    >
    >
    >
    >
    > This is important because you don't really want to get confused with all your types. What if shop_again was later changed to be True when a button was clicked. Why on earth would you set it to "y"? You'd set it to True. Thus, the sensible option is to have your types right from the very start.
    >
    >
    >
    > print("Welcome to the Star Wars Shop!")
    >
    >
    > customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
    >
    >
    >
    > eval(input(TEXT)) is a *bad* idea.
    >
    >
    > First of all, eval is really dangerous. Answer "yes" instead and it'll just crash. Answer True and it'll run... BUT do *neither* the if or the elif!That's *bad*.
    >
    >
    > Secondly, you don't need it. Your:
    >
    >
    > "if(customer == 1)" could be "if(customer == '1')", which would work without the eval.
    >
    >
    > And then you've got the standard of "Y/N". So a better question would be:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ")
    >
    >
    > Finally, you want to accept "Y" *and* "y", so you'd really want:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    >
    >
    > ---------
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    >
    >
    > Because customer really deserves to be boolean [True/False], you'd want to change it immediately.
    >
    >
    > customer = (customer == "y")
    >
    >
    > This second line assumes that all non-"y"s are False, but that's a folly you'll have to live with for now.
    >
    >
    >
    > while shop_again == 'y':
    >
    >
    >
    >
    >
    > If you've changed shop_again to be boolean:
    >
    >
    > while shop_again:
    >  
    > Some people don't get how this line would make sense. But it does. The "while" statement only cares if it's value it gets is "truthy". Here are lotsof truthy things:
    >
    >
    >
    >
    > "y" == "y"
    > True
    > False == False
    > not False
    > "egg loaf"
    > [1, 2, 1, False, False]
    >
    >
    > and here are some falsy things:
    >
    >
    >
    >
    > "n" == "y"
    > False
    > True == False
    > not True
    > ""
    > []
    >
    >
    > If this makes no sense, please just say.
    >
    >
    >
    >     if (customer == 2):
    >
    >
    >
    >
    >
    > Again, if you've done my changes from above:
    >
    >
    >
    > if not customer:
    >  
    >
    >         print("Welcome to the Star Wars Memorabilia Shop!")
    >         customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
    >
    >
    >
    > Again:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    > customer = (customer == "y")
    >
    >  
    > BUT HOLD ON!
    >
    >
    > Run your program and then answer "2" twice. What happens? It's not good.
    >
    >
    >
    >
    > The problem is that answering "2" to this second one doesn't skip the loop!
    >
    >
    > x = ASK
    > LOOP:
    >     if not x:
    >         ASK
    >     if x:
    >
    >
    >         STUFF
    >     MORE STUFF
    >
    >
    > Where you want:
    >
    >
    >
    > x = ASK
    > LOOP:
    >     if not x:
    >         ASK
    >     if x:
    >         STUFF
    >
    >
    >         MORE STUFF
    >
    >
    > or (even better):
    >
    >
    > while not x:
    >     x = ASK
    > LOOP:
    >     STUFF
    >     MORE STUFF
    >
    >
    > The second is what I've just decided to call the "ask-until-yes" model. Basically, you ask until you get a "yes", so you don't have to put the loop anywhere else. By the time the first loop is over, you *know* that x is True!
    >
    >
    >
    >     elif (customer == 1):
    >
    >
    >
    >
    >
    >
    > Again, if you've done my changes from above:
    >
    >
    >
    > elif customer:
    >  
    >
    >         print("Please select an item to update your order and anyother number to check out.")
    >         print("Yoda Figure: $10 each.")
    >         print("Star Wars Movie DVD: $20 each.")
    >
    >
    >         print("Death Star Lego Set: $200 each.")
    >         print(" 1 for Yoda Figure")
    >         print(" 2 for Star Wars Movie DVD")
    >         print(" 3 for Death Star Lego Set")
    >
    >
    >     order = eval(input("Order: "))
    >
    >
    >
    > Again:
    >
    >
    > order = input("Order number: ")
    >  
    >
    >     if (order == 1):
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "1":
    >  
    >
    >         yoda = eval(input("How many Yoda Figures do you want? :"))
    >
    >         total = 10 * yoda
    >
    >
    > Ooookkay. Now you're thinking: "BUT *surely* I need eval here!!(?)".
    >
    >
    > You don't.
    >
    >
    > yoda = int(input("How many Yoda Figures do you want? : "))
    >
    >
    >
    >
    > This is better because there are so many problems with eval, and int alsomeans that you can only order whole numbers of yodas.
    > You probably also want to call this "number_of_yodas", because you're notdefining what "yoda" is.
    >
    >
    >          print("Total:", total)
    >
    >         print("Current order:", yoda, "at", total)
    >
    >     if (order == 2):
    >
    >
    >
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "2":
    >  
    >
    >         movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
    >
    >         total = 20 * movie
    >
    >
    > As above:
    >
    >
    > number_of_movies = int(input("How many Star Wars Movie DVDs do you want? : "))
    >
    > total = 20 * number_of_movies 
    >
    >
    >
    >         print("Total:", total)
    >
    >         print("Current order:", movie, "at", total)
    >
    >     if (order == 3):
    >
    >
    >
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "3":
    >  
    >
    >         legos = eval(input("How many Death Star Lego Sets do you want? : "))
    >
    >         total = 200 * legos
    >
    >
    >
    > As above:
    >
    >
    > number_of_legos = int(input("How many Death Star Lego Sets do you want?: "))
    >
    > total = 20 * number_of_legos
    >
    >
    >          print("Total:", total)
    >
    >         print("Current order:", legos, "at", total)
    >
    >
    >
    >
    >     shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N' for no: ")
    >
    >
    > Again:
    >
    >
    > shop_again = input("Would you like to keep shopping? [Y/N]> ").lower()
    >
    >
    >
    > shop_again = (shop_again == "y")
    >  
    >
    >     print()print("Your order before shipping and discounts: ",total)
    >
    > print()
    >
    > print("Answer a trivia question for a discount!")
    >
    > discount = eval(input("On what planet did Yoda live when Luke Skywalkerfirst met him? 1) Earth 2) Dagobah 3) Pluto :"))
    >
    >
    > Again:
    >
    >
    > discount = input("On what planet did Yoda live when Luke Skywalker first met him? 1) Earth 2) Dagobah 3) Pluto :")
    >
    >
    >
    > if (discount == 1):
    >
    >     print("Sorry, that answer was wrong!")
    >
    > if (discount == 2):    print("That's correct, you get a 10% discount!")
    >
    > if (discount == 3):
    >
    >     print("Sorry, that answer was wrong!") 
    >
    >
    > If you've taken my advice:
    >
    >
    >  if discount == "1":
    >     print("Sorry, that answer was wrong!")
    >
    >
    > if discount == "2":
    >     print("That's correct, you get a 10% discount!")
    > if discount == "3":
    >     print("Sorry, that answer was wrong!") 
    >
    >
    >  print()
    >
    > if (discount == 2):
    >
    >
    > If you've taken my advice:
    >
    >
    >
    > if discount == "2":
    >
    >  
    >
    >     (total * .9)
    >
    >
    > Hold on! What do you think this line does? What is it meant to do?
    >
    >
    > You meant:
    >
    >
    > total = total*.9
    >
    >
    > Which for clarity should be written:
    >
    >
    >
    >
    > total = total * 0.9
    >
    >  
    >
    >     print("Your total before shipping: ",total) 
    >
    >  print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) Express Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 business days, free.")
    >
    > shipping = eval(input("Please select the shipping method you want: "))
    >
    >
    >
    >
    > Again:
    > shipping = input("Please select the shipping method you want: ")
    >
    >
    >
    > if (shipping == 1):
    >
    >
    >
    > If you've taken my advice:
    >
    > <br...
    > Show original
     
    , Dec 27, 2012
    #5
  6. Guest

    I cannot tell you how grateful I am that you took the time to do all of this. I have been working on it all day and you are a better teacher in a fewminutes than my teacher has been in 4 months. THANK YOU!

    And thank you again, Mitya. I really appreciate your time and effort too! Someday I'll be advanced enough to understand it lol

    I'm going to take a break and work on it more tomorrow. I'll be back.

    Thank you!


    On Wednesday, December 26, 2012 6:57:39 PM UTC-5, Joshua Landau wrote:
    > THIS IS A LONG POST, BUT IF YOU WANT TO LEARN YOU SHOULD READ IT. SERIOUSLY.
    >
    >
    > UNLIKE Mitya Sirenef's THIS DOES NOT ASSUME MORE KNOWLEDGE THAN IS IN YOUR POST ALREADY, ALTHOUGH HIS IS DEFINITELY BETTER OVERALL. AS SUCH, THERE ARE NO FUNCTIONS.
    >
    >
    >
    > OK. There are several small errors in here, but there's nothing too largeor worth much worry.
    >
    >
    >
    > On 26 December 2012 21:40, <> wrote:
    >
    >
    > I really hope you can help!
    >
    > I need to create a program where the user can order any combination and quantity of 3 products. I then offer a 10% discount if the customer correctly answers a trivia question.  After that, there are 3 choices for shipping.
    >
    >
    >
    > I have most of the program completed but I'm struggling with the most important parts :/  I get the total of multiple orders of the same item, butwe can't figure out how to total the entire order - before discounts and shipping - and then where to put any code referring back to the trivia question. Can somebody please help me with this? I would really appreciate it!
    >
    >
    >
    >
    >
    > You write that you "need" to do this, which may hint that this is some sort of homework. If so, it's generally a nice thing to say as much. That said, as long as you've given a good shot at it it's normally fine.
    >
    >
    >  This is the code:
    >
    >
    >
    >
    >
    > My *very first* thought about this code is that it's really badly spaced.Don't put lines together so much! [https://gist.github.com/4383950] shows how much nicer things look when they're partitioned more. You may not agree, but it took about 10 seconds and I prefer it.
    >
    >
    >  shop_again = 'y'
    >
    >
    >
    >
    >
    > Hold on! Hold on!
    > shop_again should have a True/False value. It is screaming to be a boolean. "y" is a letter, not a boolean. Thus:
    >
    >
    > shop_again = True
    >
    >
    >
    >
    > This is important because you don't really want to get confused with all your types. What if shop_again was later changed to be True when a button was clicked. Why on earth would you set it to "y"? You'd set it to True. Thus, the sensible option is to have your types right from the very start.
    >
    >
    >
    > print("Welcome to the Star Wars Shop!")
    >
    >
    > customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
    >
    >
    >
    > eval(input(TEXT)) is a *bad* idea.
    >
    >
    > First of all, eval is really dangerous. Answer "yes" instead and it'll just crash. Answer True and it'll run... BUT do *neither* the if or the elif!That's *bad*.
    >
    >
    > Secondly, you don't need it. Your:
    >
    >
    > "if(customer == 1)" could be "if(customer == '1')", which would work without the eval.
    >
    >
    > And then you've got the standard of "Y/N". So a better question would be:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ")
    >
    >
    > Finally, you want to accept "Y" *and* "y", so you'd really want:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    >
    >
    > ---------
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    >
    >
    > Because customer really deserves to be boolean [True/False], you'd want to change it immediately.
    >
    >
    > customer = (customer == "y")
    >
    >
    > This second line assumes that all non-"y"s are False, but that's a folly you'll have to live with for now.
    >
    >
    >
    > while shop_again == 'y':
    >
    >
    >
    >
    >
    > If you've changed shop_again to be boolean:
    >
    >
    > while shop_again:
    >  
    > Some people don't get how this line would make sense. But it does. The "while" statement only cares if it's value it gets is "truthy". Here are lotsof truthy things:
    >
    >
    >
    >
    > "y" == "y"
    > True
    > False == False
    > not False
    > "egg loaf"
    > [1, 2, 1, False, False]
    >
    >
    > and here are some falsy things:
    >
    >
    >
    >
    > "n" == "y"
    > False
    > True == False
    > not True
    > ""
    > []
    >
    >
    > If this makes no sense, please just say.
    >
    >
    >
    >     if (customer == 2):
    >
    >
    >
    >
    >
    > Again, if you've done my changes from above:
    >
    >
    >
    > if not customer:
    >  
    >
    >         print("Welcome to the Star Wars Memorabilia Shop!")
    >         customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
    >
    >
    >
    > Again:
    >
    >
    >
    >
    > customer = input("Is there a customer in line? [Y/N]> ").lower()
    >
    > customer = (customer == "y")
    >
    >  
    > BUT HOLD ON!
    >
    >
    > Run your program and then answer "2" twice. What happens? It's not good.
    >
    >
    >
    >
    > The problem is that answering "2" to this second one doesn't skip the loop!
    >
    >
    > x = ASK
    > LOOP:
    >     if not x:
    >         ASK
    >     if x:
    >
    >
    >         STUFF
    >     MORE STUFF
    >
    >
    > Where you want:
    >
    >
    >
    > x = ASK
    > LOOP:
    >     if not x:
    >         ASK
    >     if x:
    >         STUFF
    >
    >
    >         MORE STUFF
    >
    >
    > or (even better):
    >
    >
    > while not x:
    >     x = ASK
    > LOOP:
    >     STUFF
    >     MORE STUFF
    >
    >
    > The second is what I've just decided to call the "ask-until-yes" model. Basically, you ask until you get a "yes", so you don't have to put the loop anywhere else. By the time the first loop is over, you *know* that x is True!
    >
    >
    >
    >     elif (customer == 1):
    >
    >
    >
    >
    >
    >
    > Again, if you've done my changes from above:
    >
    >
    >
    > elif customer:
    >  
    >
    >         print("Please select an item to update your order and anyother number to check out.")
    >         print("Yoda Figure: $10 each.")
    >         print("Star Wars Movie DVD: $20 each.")
    >
    >
    >         print("Death Star Lego Set: $200 each.")
    >         print(" 1 for Yoda Figure")
    >         print(" 2 for Star Wars Movie DVD")
    >         print(" 3 for Death Star Lego Set")
    >
    >
    >     order = eval(input("Order: "))
    >
    >
    >
    > Again:
    >
    >
    > order = input("Order number: ")
    >  
    >
    >     if (order == 1):
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "1":
    >  
    >
    >         yoda = eval(input("How many Yoda Figures do you want? :"))
    >
    >         total = 10 * yoda
    >
    >
    > Ooookkay. Now you're thinking: "BUT *surely* I need eval here!!(?)".
    >
    >
    > You don't.
    >
    >
    > yoda = int(input("How many Yoda Figures do you want? : "))
    >
    >
    >
    >
    > This is better because there are so many problems with eval, and int alsomeans that you can only order whole numbers of yodas.
    > You probably also want to call this "number_of_yodas", because you're notdefining what "yoda" is.
    >
    >
    >          print("Total:", total)
    >
    >         print("Current order:", yoda, "at", total)
    >
    >     if (order == 2):
    >
    >
    >
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "2":
    >  
    >
    >         movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
    >
    >         total = 20 * movie
    >
    >
    > As above:
    >
    >
    > number_of_movies = int(input("How many Star Wars Movie DVDs do you want? : "))
    >
    > total = 20 * number_of_movies 
    >
    >
    >
    >         print("Total:", total)
    >
    >         print("Current order:", movie, "at", total)
    >
    >     if (order == 3):
    >
    >
    >
    >
    >
    > If you've followed my advice:
    >
    >
    > if order == "3":
    >  
    >
    >         legos = eval(input("How many Death Star Lego Sets do you want? : "))
    >
    >         total = 200 * legos
    >
    >
    >
    > As above:
    >
    >
    > number_of_legos = int(input("How many Death Star Lego Sets do you want?: "))
    >
    > total = 20 * number_of_legos
    >
    >
    >          print("Total:", total)
    >
    >         print("Current order:", legos, "at", total)
    >
    >
    >
    >
    >     shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N' for no: ")
    >
    >
    > Again:
    >
    >
    > shop_again = input("Would you like to keep shopping? [Y/N]> ").lower()
    >
    >
    >
    > shop_again = (shop_again == "y")
    >  
    >
    >     print()print("Your order before shipping and discounts: ",total)
    >
    > print()
    >
    > print("Answer a trivia question for a discount!")
    >
    > discount = eval(input("On what planet did Yoda live when Luke Skywalkerfirst met him? 1) Earth 2) Dagobah 3) Pluto :"))
    >
    >
    > Again:
    >
    >
    > discount = input("On what planet did Yoda live when Luke Skywalker first met him? 1) Earth 2) Dagobah 3) Pluto :")
    >
    >
    >
    > if (discount == 1):
    >
    >     print("Sorry, that answer was wrong!")
    >
    > if (discount == 2):    print("That's correct, you get a 10% discount!")
    >
    > if (discount == 3):
    >
    >     print("Sorry, that answer was wrong!") 
    >
    >
    > If you've taken my advice:
    >
    >
    >  if discount == "1":
    >     print("Sorry, that answer was wrong!")
    >
    >
    > if discount == "2":
    >     print("That's correct, you get a 10% discount!")
    > if discount == "3":
    >     print("Sorry, that answer was wrong!") 
    >
    >
    >  print()
    >
    > if (discount == 2):
    >
    >
    > If you've taken my advice:
    >
    >
    >
    > if discount == "2":
    >
    >  
    >
    >     (total * .9)
    >
    >
    > Hold on! What do you think this line does? What is it meant to do?
    >
    >
    > You meant:
    >
    >
    > total = total*.9
    >
    >
    > Which for clarity should be written:
    >
    >
    >
    >
    > total = total * 0.9
    >
    >  
    >
    >     print("Your total before shipping: ",total) 
    >
    >  print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) Express Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 business days, free.")
    >
    > shipping = eval(input("Please select the shipping method you want: "))
    >
    >
    >
    >
    > Again:
    > shipping = input("Please select the shipping method you want: ")
    >
    >
    >
    > if (shipping == 1):
    >
    >
    >
    > If you've taken my advice:
    >
    > <br...
    > Show original
     
    , Dec 27, 2012
    #6
  7. On Thu, Dec 27, 2012 at 11:04 AM, <> wrote:
    > Second, I honestly have no idea how to answer your questions. I am a sophomore in high school and I am trying to learn this on my own because my teacher is not very good at explaining things.


    Unfortunately, there are a great many bad programming courses out
    there - either because the course material itself is flawed, or
    because it's being delivered by someone who isn't good at teaching.
    But fortunately, with Python, you don't need a course at all! Check
    this out:

    http://docs.python.org/3/tutorial/index.html

    You may even be able to work through the tutorial (actually _do_ the
    examples, btw) in less time than it would take to solve your problem
    by asking here - it takes time to formulate questions, more time to
    wait for responses, and then the response may or may not make good
    sense to you. It's an excellent tutorial; I strongly recommend it to
    people new to Python, whether they're experienced programmers with
    other languages or totally new to coding.

    > i just cant figure out how to get the total when an order is placed without the customer ordering at least one of each item. I also can't figure out how to get the shipping to calculate correctly. It is an intro class and we are using just the basics. Most of what Mitya said is stuff I've never seen before, although I am very grateful for her response, I am supposed to use only what the teacher "taught".
    >
    > Sorry if I frustrated you. I'm just a kid trying to learn. Any help is appreciated


    The rule that you should use only what you've been taught is a
    restriction, and yes, restrictions may feel annoying. But it actually
    makes your task easier. Why? Because you have a guarantee (assuming
    the course material isn't so fundamentally flawed as to make the task
    impossible) that the goal can be achieved with just those tools. You
    probably haven't, for instance, been taught about building a dispatch
    table using a dictionary and a collection of functions, so you don't
    need to worry about coding that way (as an aside, it's a quite viable
    way to write something like this).

    Once you understand the problem AND understand the tools you're
    working with, it's up to you to figure out how to combine your
    available tools to solve the problem. That's a fundamental of all
    programming and, truth to tell, all of life. But it starts with
    understanding both halves, so to that end I think Mitya's post is
    quite useful even if the code itself does things you "haven't been
    taught". You'll just need to do some code massaging at the end.

    Best of luck in the course. Try not to let it scare you off coding -
    it's a wonderful world out here, unfathomable powah is unleashed by a
    few keystrokes!

    ChrisA
    import antigravity
     
    Chris Angelico, Dec 27, 2012
    #7
  8. On 12/26/2012 07:04 PM, wrote:
    > First, sorry for starting a new post - I didn't want anyone to have to read through the whole first one when the questions were completely different :/
    >
    > Second, I honestly have no idea how to answer your questions. I am a sophomore in high school and I am trying to learn this on my own because my teacher is not very good at explaining things.
    >
    > i just cant figure out how to get the total when an order is placed without the customer ordering at least one of each item. I also can't figure out how to get the shipping to calculate correctly. It is an intro class and we are using just the basics. Most of what Mitya said is stuff I've never seen before, although I am very grateful for her response, I am supposed to use only what the teacher "taught".



    I'm sorry to hear that, I just want to clarify - the teacher did not yet
    cover
    the use of lists, dictionaries and functions?

    If that's the case, I have to agree with you that he's probably not a very
    good teacher because this task can be done much easier and better
    with those 3 concepts, all of which are very easy. If you are barred from
    using them, Joshua's post will be most helpful.

    If you are curious about the 3 concepts I mentioned, they are covered
    in the official python tutorial, but the quick rundown is:

    list: a list of items, e.g. a shopping list:

    shoplist = ["tea", "cake", "blueberries"]

    dictionary: a collection of keys/values, like words/definitions in a
    dictionary:

    shopping_cart = {"yoda": 3, "dvd": 5} # 3 of yoda figures, 5 dvds


    function: a way to group a bunch of code together:

    def main():
    # do something
    # do something else
    # la la la

    main()

    The nice thing about functions is that if you need to repeat
    something, let's say, two thousand times, you just call the
    function two thousand times, e.g.:

    for x in range(2000): main()

    Which is much easier than typing in two thousand copies of the same code
    (don't ask me how I know!)

    - mitya


    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
     
    Mitya Sirenef, Dec 27, 2012
    #8
  9. On Thu, Dec 27, 2012 at 11:45 AM, Joshua Landau
    <> wrote:
    > FINALLY:
    > When you use Google Groups, your quotations look to us like this:
    >
    >> This is something I said
    >>
    >> with lots of extra
    >>
    >> lines in the middle
    >>
    >> for no reason. Google
    >>
    >> Groups sucks, basically.

    >
    > So please just delete the part where you quote other people. I think there
    > are other ways of quoting properly, but you might as well just not quote.
    > (When you quoted my post, the result was *literally* twice as long!)
    >


    One of the regulars on the list has posted a run-down of how to post
    from Google Groups without annoying everyone, and among other things,
    it recommends manually deleting all the blank lines. To my mind,
    though, this would be insane and inane tedium. I recommend signing up
    to the mailing list; see
    http://mail.python.org/mailman/listinfo/python-list for details. (As
    an aside, the mailing list is run by Mailman, which is written in
    Python. So we use Python to discuss Python.)

    ChrisA
     
    Chris Angelico, Dec 27, 2012
    #9
  10. On 12/26/2012 08:00 PM, Chris Angelico wrote:
    > On Thu, Dec 27, 2012 at 11:45 AM, Joshua Landau
    > <> wrote:
    >> FINALLY:
    >> When you use Google Groups, your quotations look to us like this:
    >>
    >>> This is something I said
    >>>
    >>> with lots of extra
    >>>
    >>> lines in the middle
    >>>
    >>> for no reason. Google
    >>>
    >>> Groups sucks, basically.

    >> So please just delete the part where you quote other people. I think there
    >> are other ways of quoting properly, but you might as well just not quote.
    >> (When you quoted my post, the result was *literally* twice as long!)
    >>

    > One of the regulars on the list has posted a run-down of how to post
    > from Google Groups without annoying everyone, and among other things,
    > it recommends manually deleting all the blank lines. To my mind,
    > though, this would be insane and inane tedium. I recommend signing up



    I have to agree - I saw that howto as well and it occurred to me
    that if we have to delete blank lines manually we might
    as well use postal pigeons with tiny little papyrus scrolls -
    at least those don't insert blank lines automatically!

    -m

    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
     
    Mitya Sirenef, Dec 27, 2012
    #10
  11. On Thu, Dec 27, 2012 at 12:17 PM, Mitya Sirenef <> wrote:
    > I have to agree - I saw that howto as well and it occurred to me
    > that if we have to delete blank lines manually we might
    > as well use postal pigeons with tiny little papyrus scrolls -
    > at least those don't insert blank lines automatically!


    Yes, but they have poor latency, and packet loss due to hawks is a
    major problem. But an RFC 1149 network is plausible, even if not
    viable in most situations.

    ChrisA
     
    Chris Angelico, Dec 27, 2012
    #11
  12. On 12/26/2012 08:23 PM, Chris Angelico wrote:
    > On Thu, Dec 27, 2012 at 12:17 PM, Mitya Sirenef <> wrote:
    >> I have to agree - I saw that howto as well and it occurred to me
    >> that if we have to delete blank lines manually we might
    >> as well use postal pigeons with tiny little papyrus scrolls -
    >> at least those don't insert blank lines automatically!

    > Yes, but they have poor latency, and packet loss due to hawks is a
    > major problem. But an RFC 1149 network is plausible, even if not
    > viable in most situations.
    >
    > ChrisA


    I don't know, I played starcraft II by pigeon-net and it
    worked just fine. Yes, latency is quite bad but it gives
    you more time to think about strategy...

    -m

    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
     
    Mitya Sirenef, Dec 27, 2012
    #12
  13. On Wed, 26 Dec 2012 20:17:25 -0500, Mitya Sirenef
    <> declaimed the following in
    gmane.comp.python.general:


    > I have to agree - I saw that howto as well and it occurred to me
    > that if we have to delete blank lines manually we might
    > as well use postal pigeons with tiny little papyrus scrolls -
    > at least those don't insert blank lines automatically!
    >

    http://news.google.com/newspapers?n...RYzAAAAIBAJ&sjid=XTIHAAAAIBAJ&pg=5615,6417579
    A few decades old, but...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Dec 27, 2012
    #13
  14. alex23 Guest

    On 27 Dec, 11:00, Chris Angelico <> wrote:
    > One of the regulars on the list has posted a run-down of how to post
    > from Google Groups without annoying everyone, and among other things,
    > it recommends manually deleting all the blank lines.


    I'm still posting via Groups and am not seeing my posts come through
    with blank lines or weird formatting.

    However, I _am_ regularly (every goddamn day, thanks for nothing,
    Google) telling the new UI to bugger off and reverting to the old,
    sane, thread-on-one-page-not-three UI. I think the issues are with the
    new UI, which just further reinforces my belief that Google are trying
    to just kill Groups dead.
     
    alex23, Dec 27, 2012
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Dixson
    Replies:
    1
    Views:
    522
    Joe Fallon
    May 18, 2004
  2. Replies:
    4
    Views:
    541
    Chris Uppal
    May 5, 2005
  3. hilz
    Replies:
    13
    Views:
    640
  4. KK
    Replies:
    2
    Views:
    647
    Big Brian
    Oct 14, 2003
  5. Replies:
    1
    Views:
    413
    Knute Johnson
    Sep 26, 2006
Loading...

Share This Page