Now You Code 3: Shopping Cart

In this program you will implement an online shopping cart using a Python list of dictionary. The dictionary will contain the product name, price and quantity.

The program should loop continually, asking the user to enter

  • Product name
  • Product price
  • Product quantity

until the user enters a product name of 'checkout' at which time the loop should break.

Each time through the loop you should create a dictionary of product name, product price and product quantity then add the dictionary to a list.

After you enter 'checkout' the program should show:

  • all the items in the cart, including their quantity and price
  • and the total amount of the order, a running sum of quantity times price

NOTE: Don't worry about handling bad inputs for this exercise.

Example Run:

E-Commerce Shopping Cart
Enter product name or 'checkout':pencil
Enter pencil Price:0.99
Enter pencil Quantity:10
Enter product name or 'checkout':calculator
Enter calculator Price:9.99
Enter calculator Quantity:1
Enter product name or 'checkout':checkout
pencil 10 $0.99
calculator 1 $9.99
TOTAL: $19.89

Start out your program by writing your TODO list of steps you'll need to solve the problem!

Step 1: Problem Analysis

Inputs:

Outputs:

Algorithm (Steps in Program):

write algorithm here

In [2]:
# STEP 2: Write code

Step 3: Questions

  1. How does using a Python dictionary simplify this program? (Think of how you would have to write this program if you did not use a dictionary)

Answer:

  1. What Happens when you run the program and just type checkout. Does the program work as you would expect?

Answer:

Step 4: Reflection

Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?

To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.

Keep your response to between 100 and 250 words.

--== Write Your Reflection Below Here ==--


In [ ]:
# RUN THIS CODE CELL TO TURN IN YOUR WORK!
from ist256.submission import Submission
Submission().submit()