This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

# Python Financial assistance: somebody can help me to fix my code script and fix errors. thanks

tainguyen3

Financial Assistance:
A non-governmental organization needs a program to calculate the amount of financial assistance for needy families.
The formula is as follows:
• If the annual household income is between \$30,000 and \$40,000 and the household has at least three children, the amount is \$1,000 per child.
• If the annual household income is between \$20,000 and \$30,000 and the household has at least two children, the amount is \$1,500 per child.
• If the annual household income is less than \$20,000, the amount is \$2,000 per child. Write a program that asks for the house-hold income and number of children for each applicant, printing the amount returned by your function.
Input function Specs 1. def get_income() This function requests an annual household income from the user and continues to ask for the income value unntil the user gets it right. This function should not accept any arguments.

1. def get_number() This function requests a number of children and continues to ask for the number until the user gets it right. This function should not accept any arguments.
2. def compute_assistance(income, number) This function accepts both the annual household income and the number of children as parameters and return the amount of financial assistance.

def computeAssistance(income, children):
returnString = ""
#check the range that income falls in

if income in range(30000, 40000):
assistance = 1000
returnString += "Assistance: \$"+ str(assistance)+"/child \n"
returnString += "Total assistance: \$" + str(assistance * children)
elif income in range(20000, 30000):
assistance = 1500
returnString += "Assistance: \$"+str(assistance)+"/child\n"
returnString += "Total assistance: \$" + str(assistance * children)
elif income in range(0, 20000):
assistance = 2000
returnString += "Assistance: \$"+ str (assistance)+"/child\n"
returnString += "Total assistance: \$"+ str (assistance*children)
else:
returnString += "No assistance"
return returnString

#display welcome message

print("Welcome to household financial assistance calculator.")
print("Enter -1 to exit.")
try:
while True:

#prompt user for income and no. of

childrenincome = int(input("Please enter household income amount: \n"))
if income == -1:
exit()