Question: Code a function that accepts 1 ) Accept a monthly budget value 2 ) A maximum expense value 3 ) A dictionary of expenses with

Code a function that accepts
1) Accept a monthly budget value
2) A maximum expense value
3) A dictionary of expenses with the folllowing keys-value pair
key = expense name: string value
value = expense price: int/float value
Iterate the dictionary of values and return one of the following values
True & sum of all expenses: if the sum of all expenses is less than or equal to the monthly budget value
False & sum of all expenses: if the sum of all expenses is greater than the monthly budget value
False, the expense name & the expense value of the FIRST expense that is greater than the maximum expense value
NOTE: you are required to add the neccessary paramaters, method body and return statement.
NOTE: error handling is not expected of you, assume that if the values passed will be int, int and dictionary
>>> task2(100,40,{'food': 20, 'fun': 15, 'clothes': 30, 'travel': 25})
(True,90)
>>> task2(150,35,{'food': 30, 'books': 35, 'internet': 40, 'streaming services': 15})
(False, 'internet', 40)
>>> task2(180,40,{'food': 30, 'fun': 25, 'clothes': 30, 'travel': 25, 'books': 35, 'internet': 40, 'streaming services': 15})
(False,200)
>>> task2(300,50,{'coat': 30, 'jeans': 20, 'hat': 15, 'scarf': 10, 'boots': 40, 'socks': 5, 'food': 20, 'fun': 15, 'clothes': 30, 'travel': 25})
(True,210)
>>> task2(500,100,{'coffee': 40, 'restaurant': 200, 'travel': 50, 'plan ticket': 350, 'school': 90})
(False, 'restaurant', 200)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!