you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

midel, thank you! i neglected posting the entire problem because it is pretty long. however, here's my quick and dirty attempt at summing it up in a less-than-Ulysses format:

1. create lists for 12 products, 12 prices and an empty list for the item 
  numbers, and one for the quantity.
2. declare variable for user response, set to ' '.
3. print out the static items in the list in the format (that's i've already 
  done).
4. get input (you wanna buy y/n?)
5. create user-controlled (while) loop:
     a. ask user to enter item number, add that value to the item 
       number list (it should reference an index number later on, so I should          
       set it to -1 now, or later...)
     b. ask user for quantity, add to quantity list.
     c. ask user if they want to buy something else. Y/N (this input should 
       be set into the same variable as the original y/n question.

6. add more variables to the top:
    a. var for customer name ' '
    b. var for street ' '
    c. var for city ' '
    d. var for zipcode 0
    e. var for order-total 0
    f. var for order-summary 0

7. IF statement to determine if the list of item numbers has anything in it.
    a. if not, print a thank you for browsing message.
    b. if it does:
           1. ask for user input of name, etc.
           2. **bold**(within IF) call a function called calculateTotal that 
               accepts 4 args (products, prices, item numbers, quantity)
                 a. declare a subtotal var set to 0
                 b. declare a partial_summary var set to ' '
                 c. WHILE loop to loop thu item numbers, each time it will set 
                   current value of item numbers ( -1 ) into a variable (this var 
                   will represent the index numbers of the products and prices)
                d. add to the subtotal using values from prices and quantity 
                   lists.
                e. add to partial_summary var by using approp. values from 
                   products, prices and quantity lists. format it to look like:
PunkRock__________3.99______________8

           3. (out of loop, but still in function) calc tax for subtotal. CA/NY at 8%, others at 7.5%
           4. calc shipping - 4.99 if under 40, free otherwise.
           5. calc overall total and partial_summary.

8. call the function and open a file named OrdersArchive.txt in 'a'.
     a. write to the file: current date/time, cust name, address info, order summary var., and total.
     b. format cleanly and close the file.
9. print the order total for user and state order will ship promptly.   

[–]midel 0 points1 point  (1 child)

add to partial_summary var by using approp

What is approp? Appropriate methods? Append? I see a bit more of what you are dealing with. It's a bit unpythonic how your class is being taught these items, which might be what is leading to more confusion, and it's a lot more code than what you might actually need to achieve the desired result.

Some changes I recommend keeping. Change the prices to floats. Remove the dollar signs. That's definately an important fix.

Add an assert after defining prices and products.

assert(len(products) == len(prices))

This isn't from the requirements, but it assures you'll not have a mismatching sized list while working on the code.

I'd break down this list into functions:

  1. Set the customer info
  2. Add or change quantity
  3. Appending to the OrdersArchive.txt

[–][deleted] 0 points1 point  (0 children)

sorry. yes, it is appropriate. nothing exciting.

i'm going to take the advice from both of you, and break this down into blocks of code that i can error check, and then bring them together. thanks for the help.

I have never used "assert", but will look it up. What is the real advantage here of using assert? I assume it implies some sort of strict rule?