Hello!

Hope you guys are fine.  I am a newbie in programming, though I have been 
experimenting with Python for close to 3 years, but have never attempt writing 
any real-life program.  However, recently I decided to embark on a personal 
project to develop a Python App which I want to dedicate to my community to 
solve a particular calculation challenge relating to financial benefits 
involving a combination of beneficiaries with different level of benefits.  My 
intention is to use Python 3.4 or 2.7, with Tkinter and Python Megawidgets 
(Pmw) for the GUI.  The following is a short description of the workings of the 
proposed app:

1.   The user inputs the amount to be distributed to the beneficiaries into a 
text entry box;

2.   He clicks add button, to add the value;

3.   He selects the beneficiaries from a dropdown list, one at a time;

4.   He clicks an “add beneficiary” button to add to the list;

5.   He then clicks a button to calculate the amount entitled by each 
beneficiary;

6.   The application then calculates and displays the result in the following 
format:

a.   Name: Identity of the beneficiary;

b.   Percentage: the percentage he is entitled from the amount entered (eg. 
4/24, 3/12 etc);

c.   Value: the monetary value he is entitled (eg $50 for instance)

7.   The user then clicks a close button to exit the result window.

 
I don’t have much challenge setting the GUI using Tkinter and Pmw.  But my 
challenge is how to handle the data to be entered, calculate the value based on 
the percentage each beneficiary is entitled, and allocates same to him/her.  
This is because:
1.   The user can select 3 or 4 beneficiaries with different percentages;

2.   Some beneficiaries don’t have a specific percentage, but only got their 
benefits from a reminder value;

3.   Some beneficiaries can have a specific percentage and equally be entitled 
to a section of the reminder.

4.   There may be many scenarios (can extend to 1500, but I want to start 
experimenting with just 20 instances);

I am not too depth in Python but it is the language of my choice since 2010. I 
don’t know the complex methods which Python provides in order to solve this 
intricate problem for me.  I attempted using the following python codes:

<code>

# I create different categories of beneficiaries first, using a list.

cat1 = [element1, element2, element3, element4]
 
# Capture the values from the user

amount = input(“Enter Value: “)

choice = input(“Enter Beneficiary:  “)
 
# I define a defaultdict object in order to set the values for each 
beneficiary, as it allows for one-to-many relationship.

Result = defaultdict(list)

# I now use control flow statements to compare values and distribute.

if choice == cat1:
        result[cat1[0]].append((amount/6) * 1)
        result[cat1[1]].append((amount/6) * 1)
        result[cat1[2]].append((amount/6) * 2)
        result[cat1[3]].append((amount/3) * 2)
elif choice == cat2:
        …continue same approach as above.
 
</code>

My Dilemma

My challenge here is; the above approach does not provide me the necessary 
solution. Because:
1.   Let’s assume the first part of the if statement gave me the necessary 
values for the beneficiaries, but running it does not produce anything. It only 
outputs the storage location of the “result” defaultdict object.  What is the 
best approach, please?

2.   I got stocked because I can’t continue using the “if statement” for each 
and every category of beneficiaries in order to check the user input, since I 
have to create as many instance as possible;

3.   I can’t figure out how to handle the result.  Which method can I use to 
display the result based on the format given above?

4.   I presently use list to hold the list of beneficiaries. Based on the short 
description of the proposed app above, which other container is it suitable for 
holding the categories of the beneficiaries?  

I am sorry if I omit any necessary information. This is how far I have gone. I 
am always ready to provide any necessary details please. Am a newbie, but 
always ready to learn, no matter what.

Thanks in anticipation of your magnanimity.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to