Jan-09-2018, 05:53 PM
I am doing a program where you input the amount of people in your family and the ages and Gender and then it asks what do you want to spend on grocery for a certain time span. I need help figuring out how to make a algorithm to calculate the grocery list and then print it out to the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
#Tristan Fish #Mr.Reid #ICS3U #12/19/2017 #12//2017 import random #Food Groups foodGroupGrains = "Grains" foodGroupFruitsAndVegtables = "Fruits And Vegtables" foodGroupDairy = "Dairy" foodGroupProteins = "Proteins" #totalCaloriesStore #totalPriceStore #def Breakfast_Food(test): #Breakfast Foods #Layout Cost,Servings,Calories,Food Group dempstersWholeWheatBread = [ "Dempsters Whole Wheat Bread" , 2.27 , 18 , 1620 ,foodGroupGrains] dempstersWhiteBread = [ "Dempsters White Bread" , 2.27 , 18 , 1620 ,foodGroupGrains] dempstersEverythingBagels = [ "Dempsters Everything Bagels" , 2.98 , 12 , 1200 ,foodGroupGrains] galaApple = [ "Gala Apples" , 0.71 , 1 , 52 ,foodGroupFruitsAndVegtables] banana = [ "Bananas" , 0.41 , 1 , 105 ,foodGroupFruitsAndVegtables] clementines = [ "Clementines" , 2.97 , 20 , 700 ,foodGroupFruitsAndVegtables] greatValueLargeEggs = [ "Great Value Large Eggs" , 2.27 , 6 , 840 ,foodGroupProteins] nelsonMilk = [ "Nelson Milk" , 4.27 , 16 , 2080 ,foodGroupDairy] greatValueOldCheddarCheese = [ "Great Value Old Cheddar Cheese" , 4.97 , 5 , 1800 ,foodGroupDairy] GreatValueVanillaYogurt = [ "Great Value Vanilla Yogurt" , 1.77 , 6.5 , 600 ,foodGroupDairy] GreatValueOrangeJuice = [ "Great Value Orange Juice" , 1 , 4 , 440 ,foodGroupFruitsAndVegtables] def Calculator(): foodFoodGroups = [dempstersWholeWheatBread[ 4 ],dempstersWhiteBread[ 3 ],dempstersEverythingBagels[ 4 ],galaApple[ 4 ],banana[ 4 ],clementines[ 4 ],greatValueLargeEggs[ 4 ],nelsonMilk[ 4 ],greatValueOldCheddarCheese[ 4 ],GreatValueVanillaYogurt[ 4 ],GreatValueOrangeJuice[ 4 ]] foodCalories = [dempstersWholeWheatBread[ 3 ],dempstersWhiteBread[ 3 ],dempstersEverythingBagels[ 3 ],galaApple[ 3 ],banana[ 3 ],clementines[ 3 ],greatValueLargeEggs[ 3 ],nelsonMilk[ 3 ],greatValueOldCheddarCheese[ 3 ],GreatValueVanillaYogurt[ 3 ],GreatValueOrangeJuice[ 3 ]] foodServings = [dempstersWholeWheatBread[ 2 ],dempstersWhiteBread[ 2 ],dempstersEverythingBagels[ 2 ],galaApple[ 2 ],banana[ 2 ],clementines[ 2 ],greatValueLargeEggs[ 2 ],nelsonMilk[ 2 ],greatValueOldCheddarCheese[ 2 ],GreatValueVanillaYogurt[ 2 ],GreatValueOrangeJuice[ 2 ]] foodCost = [dempstersWholeWheatBread[ 1 ],dempstersWhiteBread[ 1 ],dempstersEverythingBagels[ 1 ],galaApple[ 1 ],banana[ 1 ],clementines[ 1 ],greatValueLargeEggs[ 1 ],nelsonMilk[ 1 ],greatValueOldCheddarCheese[ 1 ],GreatValueVanillaYogurt[ 1 ],GreatValueOrangeJuice[ 1 ]] foodNames = [dempstersWholeWheatBread[ 0 ],dempstersWhiteBread[ 0 ],dempstersEverythingBagels[ 0 ],galaApple[ 0 ],banana[ 0 ],clementines[ 0 ],greatValueLargeEggs[ 0 ],nelsonMilk[ 0 ],greatValueOldCheddarCheese[ 0 ],GreatValueVanillaYogurt[ 0 ],GreatValueOrangeJuice[ 0 ]] print random.choice(foodNames), random.choice(foodCost),random.choice(foodServings),random.choice(foodCalories) Calculator() def Grocery_List(test): if timeFrame = = "One Week" and moneySpent > 50 and moneySpent < 100 and peopleInFamly = = 1 and agesOfPeopleInFamly11 > 5 and agesOfPeopleInFamly11 < 10 and genderOfPeople11 = = "Male" : print ( "test" ) #Lunch Foods #Layout Cost,Servings,Calories,Food Group greatValueSlicedHam = [ 3.47 and 6 and 360 and foodGroupProteins] pillarsClubSizeSmokedTurkeyBreast = [ 8 and 4 and 1200 and foodGroupProteins] honeyGarlicMiniPepperoniSticks = [ 6.97 and 2.4 and 1400 and foodGroupProteins] strawberryBananaYop = [ 0.98 and 1 and 150 and foodGroupDairy] vanillaYop = [ 0.98 and 1 and 150 and foodGroupDairy] strawberryYop = [ 0.98 and 1 and 150 and foodGroupDairy] blueberryYop = [ 0.98 and 1 and 150 and foodGroupDairy] minuteMaidAppleJuice = [ 2.97 and 10 and 1000 and foodGroupFruitsAndVegtables] minuteMaidOrangeJuice = [ 2.97 and 10 and 1000 and foodGroupFruitsAndVegtables] lunchMateHamStackers = [ 2.97 and 1 and 260 and foodGroupGrains] toppablesCrackers = [ 2.47 and 4.5 and 2025 and foodGroupGrains] ritzOriginalCrackers = [ 2.47 and 4 and 1000 and foodGroupGrains] wheatThinsMultiGrain = [ 2.47 and 4 and 990 and foodGroupGrains] mrNoodlesChicken = [ 0.37 and 1 and 380 and foodGroupGrains] mrNoodlesBeef = [ 0.37 and 1 and 380 and foodGroupGrains] #Dinner Foods #Layout Cost,Servings,Calories,Food Group bonelessChickenBreast = [ 10 and 5 and 800 and foodGroupProteins] mapleLeafBonelessSkinlessChickenThighs = [ 10.37 and 10 and 1200 and foodGroupProteins] mapleLeafPorkBoneless = [ 10 and 6 and 1020 and foodGroupProteins] greatValueBoneLessSmokedHam = [ 10 and 15 and 1530 and foodGroupProteins] leanGroundBeefTube = [ 4.50 and 3 and 210 and foodGroupProteins] OneWorldHalelEyeRoundFastFrySteak = [ 8 and 4 and 840 and foodGroupProteins] greatValueMacaroniAndCheese = [ 0.48 and 2 and 840 and foodGroupGrains] lanciaReadyCutMacaroni = [ 1.27 and 6 and 3360 and foodGroupGrains] greatValueWholeKernalCorn = [ 0.77 and 2 and 150 and foodGroupFruitsAndVegtables] heinzAlphagettiPasta = [ 1.27 and 1 and 510 and foodGroupGrains] carrots = [ 1.47 and 3 and 558 and foodGroupFruitsAndVegtables] sweetOnions = [ 3.97 and 6 and 435 and foodGroupFruitsAndVegtables] redOnions = [ 3.97 and 6 and 1260 and foodGroupFruitsAndVegtables] #User Inputs while True : try : peopleInFamly = int ( input ( "How Many People Are In Your Famly " )) # Amount Of Weeks Do You wanna Buy Groceries For except ValueError: print ( "Invalid Input Please Try Again" ) continue else : break #If There Is Only 1 Person In your famly if peopleInFamly = = 1 : (Calculator()) agesOfPeopleInFamly11 = int ( input ( "How Old Are You " )) genderOfPeople = input ( "What Gender Are You " ) #If There Is 2 People In your famly elif peopleInFamly = = 2 : agesOfPeopleInFamly12 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople12 = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly22 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) #If There Is 3 People In your famly elif peopleInFamly = = 3 : agesOfPeopleInFamly13 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly23 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly33 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) #If There Is 4 People In your famly elif peopleInFamly = = 4 : agesOfPeopleInFamly14 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly24 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly34 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) agesOfPeopleInFamly44 = int ( input ( "How Old Is the Fourth person in your famly " )) genderOfPeople = input ( "What Gender is the Fourth person in your famly " ) #If There Is 5 People In your famly elif peopleInFamly = = 5 : agesOfPeopleInFamly15 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly25 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly35 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) agesOfPeopleInFamly45 = int ( input ( "How Old Is the Fourth person in your famly " )) genderOfPeople = input ( "What Gender is the Fourth person in your famly " ) agesOfPeopleInFamly55 = int ( input ( "How Old Is the Fifth person in your famly " )) genderOfPeople = input ( "What Gender is the Fifth person in your famly " ) #If There Is 6 People In your famly elif peopleInFamly = = 6 : agesOfPeopleInFamly16 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly26 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly36 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) agesOfPeopleInFamly46 = int ( input ( "How Old Is the Fourth person in your famly " )) genderOfPeople = input ( "What Gender is the Fourth person in your famly " ) agesOfPeopleInFamly56 = int ( input ( "How Old Is the Fifth person in your famly " )) genderOfPeople = input ( "What Gender is the Fifth person in your famly " ) agesOfPeopleInFamly66 = int ( input ( "How Old Is the Sixth person in your famly " )) genderOfPeople = input ( "What Gender is the Sixth person in your famly " ) #If There Is 7 People In your famly elif peopleInFamly = = 7 : agesOfPeopleInFamly17 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly27 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly37 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) agesOfPeopleInFamly47 = int ( input ( "How Old Is the Fourth person in your famly " )) genderOfPeople = input ( "What Gender is the Fourth person in your famly " ) agesOfPeopleInFamly57 = int ( input ( "How Old Is the Fifth person in your famly " )) genderOfPeople = input ( "What Gender is the Fifth person in your famly " ) agesOfPeopleInFamly67 = int ( input ( "How Old Is the Sixth person in your famly " )) genderOfPeople = input ( "What Gender is the Sixth person in your famly " ) agesOfPeopleInFamly77 = int ( input ( "How Old Is the Seventh person in your famly " )) genderOfPeople = input ( "What Gender is the Seventh person in your famly " ) #If There Is 8 People In your famly elif peopleInFamly = = 8 : agesOfPeopleInFamly18 = int ( input ( "How Old Is the first person in your famly " )) genderOfPeople = input ( "What Gender is the first person in your famly " ) agesOfPeopleInFamly28 = int ( input ( "How Old Is the Second person in your famly " )) genderOfPeople = input ( "What Gender is the Second person in your famly " ) agesOfPeopleInFamly38 = int ( input ( "How Old Is the Third person in your famly " )) genderOfPeople = input ( "What Gender is the Thrid person in your famly " ) agesOfPeopleInFamly48 = int ( input ( "How Old Is the Fourth person in your famly " )) genderOfPeople = input ( "What Gender is the Fourth person in your famly " ) agesOfPeopleInFamly58 = int ( input ( "How Old Is the Fifth person in your famly " )) genderOfPeople = input ( "What Gender is the Fifth person in your famly " ) agesOfPeopleInFamly68 = int ( input ( "How Old Is the Sixth person in your famly " )) genderOfPeople = input ( "What Gender is the Sixth person in your famly " ) agesOfPeopleInFamly78 = int ( input ( "How Old Is the Seventh person in your famly " )) genderOfPeople = input ( "What Gender is the Seventh person in your famly " ) agesOfPeopleInFamly88 = int ( input ( "How Old Is the Eighth person in your famly " )) genderOfPeople = input ( "What Gender is the Eighth person in your famly " ) timeFrame = input ( "How Many Weeks Would you like to buy Groceries For " ) # Asks For How Much Money Wants To Be Spend For 1 Week On Groceries if timeFrame = = "One Week" : moneySpent = int ( input ( "How Much Would You Like To Spend On Groceries For 1 Week Including Taxes " )) # Asks For How Much Money Wants To Be Spend For 2 Weeks On Groceries elif timeFrame = = "Two Weeks" : moneySpent = int ( input ( "How Much Would You Like To Spend On Groceries For 2 Weeks Including Taxes " )) # Asks For How Much Money Wants To Be Spend For 3 Weeks On Groceries elif timeFrame = = "Three Weeks" : moneySpent = int ( input ( "How Much Would You Like To Spend On Groceries For 3 Weeks Including Taxes " )) # Asks For How Much Money Wants To Be Spend For 4 Weeks On Groceries elif timeFrame = = "Four Weeks" : moneySpent = int ( input ( "How Much Would You Like To Spend On Groceries For 4 Weeks Including Taxes " )) if timeFrame = = "OneWeek" and moneySpent < 50 and moneySpent > 25 and agesOfPeopleInFamly11 > 14 and agesOfPeopleInFamly11 < 18 and genderOfPeople11 = = "Male" : print ( "Your Grocerie list is, " ) |