Python Forum
Help on a program to help with distributing food to the needy
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help on a program to help with distributing food to the needy
#8
I have made some progress towards what i want to do, not worked on it extensively yet though. I have a way to gather the data sets i need to make a better predictive program now, just need to get some of the written data from the last couple of giveaways, or take a new set of data at the new giveaway. the code I have so far is as follows:
#for use in the total() function
from fractions import Fraction

#gives the user their first instruction when they open the program
print("Press 'q' to quit the program and get a final total.")

#just a repepitive line
def lorsvalues():
    print ('Large families: ', large, ' small families: ', small)

#this function defines the first input data and how to store that data
def oneortwo():
    #declareing the necessary variables, large and small are global as they will be needed outside this function
    global large
    global small
    large = 0
    small = 0
    letter = ''
#while letter does not equal q runs this function until the user stops it
    while letter != 'q':
#We need to know whether to give more or less amount of food to each family, using 1 or 2 cards
        letter = input("Is it a large family or small? Type l for large family, s for small: ")
        if letter == 's':
            small = small + 1
            lorsvalues()
        elif letter == 'l':
            large = large + 1
            lorsvalues()
        else:
            print('......An incorrect or blank character has been entered, try the last entry again.')

#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():
    final_total = large + small
    print('***There is a final total of ',final_total, ' families***')
    lorsvalues()
    print('the ratio of large families to small families is: ' ,Fraction(large, small), ' large/small')
    
#simpoly calling the funtions we defined earlier
oneortwo()
total()
If any of you have suggestions or inputs on how to make this code neater, more intuitive, or better suited to the needs, please tell me. I looked pretty extensively beforehand and I could not find anything in the area of what is needed here. We give food to 1 or two cards, not necessarily single or family, but few people or more. We would give, say 6 ears of corn to the small family, 8 to the large, or 2 boxes of popcorn to the small, 3 to the large. The issue is that, right now, the ratio of 1's to 2's is guesswork, about how fast to give out the products, how many to 1's or 2's, was guesswork, no one even got out a calculator. The shipments are all marked with an exact amount.
Reply


Messages In This Thread
RE: Help on a program to help with distributing food to the needy - by teenspirit - Apr-06-2017, 09:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Optimization problem ( food menu ) Truman 3 3,649 Apr-01-2019, 09:28 PM
Last Post: Truman
  Packaging and Distributing App for Python 3.6 solaikannan 1 2,716 Aug-21-2017, 09:36 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020