Question

In: Computer Science

Python code Financial Assistance : A non-governmental organization needs a program to calculate the amount of...

Python code

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.

2. 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.

3. 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.

Input Errors Whenever the user makes an input error, keep at them until they get it right. Do not return from an input function until you have acquired a legal value, even if it takes years.

Solutions

Expert Solution

I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments (read them for better understanding).

Images of the Code:

Note: If the below code is missing indentation please refer code Images

Typed Code:

# a function called get_income
# no input parameters
def get_income():
  
# A infinite while loop
# this loop run infinitely until user enter a valid input
while(True):
# reading annual income from user
income=int(input("Enter your annual household income:"))
# if income is a non negative value or valid input
if(income >= 0):
# breaking the loop
break
else:
# printing the Invalid message
print("Invalid Input. Try Again")
# returning the income
return income

# a function called get_number
# no input parameters
def get_number():
# A infinite while loop
# this loop run infinitely until user enter a valid input
while(True):
# reading number of children's from user
number = int(input("Enter number of children's in your family :"))
# if children's is a non negative number or valid input
if(number >= 0):
# breaking the loop
break;
else:
# printing the Invalid message
# Asking input again
print("Invalid Input. Try Again")
# returning the number of children's
return number

# a function called compute_assistance
# with input parameters income and number
def compute_assistance(income, number):
# a variable to store financial assistance amount
financial_assistance=0;
# if income is between $30000 and $40000
# and the household has at least three children(greater than or equal to)
if(30000 <= income < 40000 and number>= 3):
# calculating financial_assistance $1000 per child
financial_assistance = number*1000
# if income is between $20000 and $30000
# and the household has at least two children(greater than or equal to)
elif(20000 <= income < 30000 and number>= 2):
# calculating financial_assistance $1500 per child
financial_assistance = number*1500
# if household income is less than $20000
elif(income<20000):
# calculating financial_assistance $2000 per child
financial_assistance = number*2000
  
# returning the financial_assistance
return financial_assistance;
  
# calling the function get_income
income=get_income()
# calling the function get_number
number=get_number()
# calling the function financial_assistance
financial_assistance=compute_assistance(income,number)
# printing the returned amount
print("The amount of financial assistance is $",financial_assistance)
#code ended here

Output:


If You Have Any Doubts. Please Ask Using Comments.

Have A Great Day!


Related Solutions

Python Explain Code #Python program class TreeNode:
Python Explain Code   #Python program class TreeNode:    def __init__(self, key):        self.key = key        self.left = None        self.right = Nonedef findMaxDifference(root, diff=float('-inf')):    if root is None:        return float('inf'), diff    leftVal, diff = findMaxDifference(root.left, diff)    rightVal, diff = findMaxDifference(root.right, diff)    currentDiff = root.key - min(leftVal, rightVal)    diff = max(diff, currentDiff)     return min(min(leftVal, rightVal), root.key), diff root = TreeNode(6)root.left = TreeNode(3)root.right = TreeNode(8)root.right.left = TreeNode(2)root.right.right = TreeNode(4)root.right.left.left = TreeNode(1)root.right.left.right = TreeNode(7)print(findMaxDifference(root)[1])
Why is it difficult to define the term NGO? (Non Governmental Organization)
Why is it difficult to define the term NGO? (Non Governmental Organization)
In python make a simple code. You are writing a code for a program that converts...
In python make a simple code. You are writing a code for a program that converts Celsius and Fahrenheit degrees together. The program should first ask the user in which unit they are entering the temperature degree (c or C for Celcius, and f or F for Fahrenheit). Then it should ask for the temperature and call the proper function to do the conversion and display the result in another unit. It should display the result with a proper message....
prepare a 500 to 700 word letter to either a government institution or non governmental organization...
prepare a 500 to 700 word letter to either a government institution or non governmental organization of your choice describing the conditions you encountered on a recent visit to an underdeveloped country. In your letter request financial assistance and / or resources for an intervention in a selected area that you feel will have the most impact on population health
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
Question A non-governmental organization intends to carry out a programme which will involve distribution of clean...
Question A non-governmental organization intends to carry out a programme which will involve distribution of clean water, soap, sanitizers, face mask and food to across all informal settlements in Nairobi County during this coronavirus pandemic period. In view of this, conduct and a comprehensive stakeholder analysis (identifying only FIVE key stakeholders) the NGO will need to engage before commencing the programme.
A non-governmental organization (ngo) introduced to subsistence farmers a modern seed variety with potential to produce...
A non-governmental organization (ngo) introduced to subsistence farmers a modern seed variety with potential to produce ten times more yield than traditional seed varieties. The likelihood of crop failure using modern seeds was higher compared to traditional seeds. The NGO was surprised that the farmers were reluctant to adopt these modern seeds. Explain using risk and uncertainty why this economic behaviour by farmers is rational? What could be done to increase adoption of modern seed varieties by farmers? Short answer...
Think carefully about the overall mission and goals of a non-governmental organization(NGO), such as Doctors Without...
Think carefully about the overall mission and goals of a non-governmental organization(NGO), such as Doctors Without borders or The Nature Conservancy. Required: How does the task of building a balanced scorecard for an NGO differ from that for a profit-seeking enterprise? Choose an NGO that interests you and design a simple balanced scoreboard for them with a minimum of two measures in each of scorecard’s perspectives
Write a function that implements the following formula to calculates the amount of financial assistance for...
Write a function that implements the following formula to calculates the amount of financial assistance for families in need: • If the annual family income is between $30,000 and $40,000 and the family has at least 3 children, the assistance amount will be $1,000 per child. • If the annual family income is between $20,000 and $30,000 and the family has at least 2 children, the assistance amount will be $1,500 per child. • If the annual family income is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT