A day at the supermarket !

Today’s lesson will be using list,dictionaries,and functions to create a program that helps us create a shopping list and how much we will be wasting for each food item will be buying for today’s lesson. For the first picture we simply practice using the For loop to print out all items in a list. The second picture we use a For loop to print out all keys in a dictionary. For the third picture will continue using the For loop except will be adding a Boolean statement in order to print out even numbers only in the list. As for the fourth picture will be creating programs using functions and list. In the fifth picture it explains that we can also loops through strings because strings are like lists with characters for elements. Once we get to the sixth picture we have finally started the main project of this lesson. Starting off our code will be creating a dictionary named price that will hold the prices for each one of our foods. For the second step will create another dictionary except this time it will be named stock representing the amount of food there is in stock at the supermarket. The third step will be looping through prices in order to get both keys from each dictionaries since they have the same keys. When we finish with that will be moving on to the next part of our program which is finding the total if we sold all our products. We do this by creating the variable total and set it to 0. Next we multiply the key values in both dictionaries and once we do that we increment total so that it knows to add all those total values of each multiplied key. For the next step we create a list of our foods. Following that step will be using a function to determine the price of each food will be buying in the list ignoring whether its in stock or not. So we set total to zero and use the For loop to go through each item then will set total to total + prices[item], that way we get the prices of our items. Next will add the Boolean statement in order for the function to only add the price if the item is in stock and next will add a statement that takes away 1 from stock because we purchased 1 item from the stock. After all this we finished with our lesson for today ” A day at the supermarket”.