Can you please help me?

2012-12-26 Thread bobflipperdoodle
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, but we 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!

This 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? : "))
total = 10 * yoda
print("Total:", total)
print("Current order:", yoda, "at", total)
if (order == 2):
movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
total = 20 * movie
print("Total:", total)
print("Current order:", movie, "at", total)
if (order == 3):
legos = eval(input("How many Death Star Lego Sets do you want? : "))
total = 200 * 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: ")
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 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 == 2):
(total * .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: "))

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!")
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Please help if you can!

2012-12-26 Thread bobflipperdoodle
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!")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can you please help me?

2012-12-26 Thread bobflipperdoodle
Thank you very much for your reply.  I actually just deleted this post as you 
were replying!  I had figured out a few things and then got confused about a 
few others :/  If you have a chance, can you look at the other post?  Thank 
you!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread bobflipperdoodle
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".

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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread bobflipperdoodle
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 few minutes 
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 large or 
> 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, but 
> we 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 lots 
> of 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 = AS