Apr-07-2017, 02:23 AM
(This post was last modified: Apr-07-2017, 03:18 AM by teenspirit.)
Ok, I have been advised to make what I need to do clearer. What I need to do is general predictions on the numbers of items to give to each family. The most important factors are:
How many of each item to give to 1's
How many of each item to give to 2's
How many people are we expecting total
What is the ratio in that total group of 1's to 2's
We have a set number of units for each item, they arrive on a truck with sheets saying how much we have of each. The main issue is that the ratio of 1's to 2's isn't always constant through and entire line, and we don't know exactly how many people will show up every time. I need to process the data, live, so that each booth knows how much to be giving out every 15-30 minutes or so. I want to make a list of items with their units and amount of units to be entered when trucks arrive, then take how much we have of everything, process it through an average of three or so runs so we have a general idea of what we are looking at for each item in terms of how many units to give out, then leave a little excess based off the predictions in case more 2's or families total show up than we expected, but distribute any of the unused surplus evenly over 15-30 minutes. The idea is to distribute the food evenly as possible over the whole group of families, but not run out or have excessive surplus's at the end. I hope that helps, if any area is unclear i will clear it up as much as possible.
Minor update to the code:
What i did here was start to prepare a dictionary that would store all the total amounts of food, that i could then manipulate later on as i dispense the food. My next step would be to finish defining that function and comment it, add another function where you add the speculative ratio or percent of 1's to 2's, add the speculative total number of people, then make a final function or two that actually claculated and updated every 50 total entries how many of each item we should be handing out to each family. I truly appreciate the community help on this, but I am off to bed now, will start as soon as i can again tomorrow.
How many of each item to give to 1's
How many of each item to give to 2's
How many people are we expecting total
What is the ratio in that total group of 1's to 2's
We have a set number of units for each item, they arrive on a truck with sheets saying how much we have of each. The main issue is that the ratio of 1's to 2's isn't always constant through and entire line, and we don't know exactly how many people will show up every time. I need to process the data, live, so that each booth knows how much to be giving out every 15-30 minutes or so. I want to make a list of items with their units and amount of units to be entered when trucks arrive, then take how much we have of everything, process it through an average of three or so runs so we have a general idea of what we are looking at for each item in terms of how many units to give out, then leave a little excess based off the predictions in case more 2's or families total show up than we expected, but distribute any of the unused surplus evenly over 15-30 minutes. The idea is to distribute the food evenly as possible over the whole group of families, but not run out or have excessive surplus's at the end. I hope that helps, if any area is unclear i will clear it up as much as possible.
Minor update to the code:
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 |
#for use in the total() function from fractions import Fraction def food_items(): item = 0 items = {} while True : item_name = input ( "Type the name of your food item here: " ) item_units = input ( "Type the number of units of your item, just the number, here: " ) items[item_name] = item_units next_step_option = input ( "Type 'a' to do another item, type 'n' to go to the next step': " ) if next_step_option = = 'a' : print ( 'Adding another food item' ) elif next_step_option = = 'n' : break else : print ( '......An incorrect or blank character has been entered, try the last entry again.' ) #just a repepitive line def show_sizes(large, small): print ( 'Large families: ' , large, ' small families: ' , small) #this function defines the first input data and how to store that data def one_or_two(): # instruction for quitting print ( "Press 'q' to quit the program and get a final total." ) #declareing the necessary variables large = 0 small = 0 while True : letter = input ( "Is it a large family or small? Type l for large family, s for small: " ).lower() if letter in ( 's' , 'small' ): #adding to the value of small families small = small + 1 show_sizes(large, small) elif letter in ( 'l' , 'large' ): #adding to the value of large families large = large + 1 show_sizes(large, small) elif letter in ( 'q' , 'quit' ): break else : print ( '......An incorrect or blank character has been entered, try the last entry again.' ) print () return large, small #this function gives a tally with information when the program is exited. I intend to make this also write to a file for better predictions in the future. def total(large, small): final_total = large + small print ( '\n***There is a final total of ' ,final_total, ' families***' ) show_sizes(large, small) print ( 'The ratio of large families to small families is: ' ,Fraction(large, small), ' large/small' ) print ( '{:.1%} of the families were large.' . format (large / final_total)) #simply calling the funtions we defined earlier food_items() large, small = one_or_two() total(large, small) |