Fresh Market Markup Solved

25.00 $ 12.50 $

Category:

Description

Foreword: As with previous assignments, this week’s assignment is to test your knowledge on the newly introduced data structures of dictionaries and lists. However, unlike previous assignments, this one introduces more of a challenge in implementing what is required as multiple concepts previously learned will be needed. To impart some words of advice, please remember looping statements, conditional statements, logic operators, formatted output, and a variety of different functions and methods as well. If you ever get stuck or are not sure how to approach a concept, consult with your classmates, or even read through the Python documentation to refresh your mind or obtain some clarity on any of the previously covered functions and methods.

 

Problem: You have been tasked in implementing a software system to speed up checkout times for a new grocery store in your area, Barg’n Shop. The owners of the shop have asked you to create an inventory of items the shop keeps in stock that lists the name of the item and its price so that the shopper may know what is available to them at the beginning of the software execution. In addition to that, they also wish that it be able to keep track of what the shopper places in their cart through a list. To ensure the best possible customer service, the owners have also asked you to include a way for the shopper to be able look (to “peak”) at what is currently in their cart. Of course, if the shopper asks for an item that is not in the inventory stock, politely let them know that is the case. Once the shopper is ready for checkout, determine to see if their cart is empty or not. If it is, let them know how much you appreciate them for dropping by their establishment. If it is not empty, calculate the total price of all items. You may assume that the tax rate is 0% in the area of the store.

 

Suggestions

  1. Use a dictionary to implement the inventory. When displaying the contents of the inventory, use a for loop that contains formatted output.
  2. Recall that the method iteritems() returns an iterator over a dictionary’s (key, value) pairings, useful in loops. Syntax: dictionary.iteritems()
  3. The “ \’ ” escape character will be needed if you wish to include a single quotation mark. This is to avoid any unintended errors in your program.
  4. Implement an infinite loop to ensure the shopper gets all the items that they need.
  5. In my program, I implemented an if / elif / elif / else conditional structure.
  6. Make use of the has_key() method to ensure that what the shopper wishes to get is actually in stock or not. Syntax: has_key(key)
  7. To add items to a list, use the append() Syntax: list.append(item)
  8. Recall that the len() function returns the size of a dictionary or a list if one is passed to it as an argument.

Sample Inputs & Outputs

 

 

 

 

Notes: Save your file as “firstname_lastname_market_markup.py”. Additionally, you are NOT required to have everything listed in the Suggestions section of this document. It is there to help you out in the implementation of this program by helpfully shedding some light on how to approach certain things. When it comes to creating the inventory of items, feel free to include whatever items you wish to have, at any price.

 

1 Assignment name suggested by Megan Boebinger, undergraduate student at Florida State University