Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Accept a monthly budget value A maximum expense value A dictionary of expenses with the folllowing keysvalue pair key expense name: string value value expense price: intfloat 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 taskfood: 'fun': 'clothes': 'travel': True taskfood: 'books': 'internet': 'streaming services': False 'internet', taskfood: 'fun': 'clothes': 'travel': 'books': 'internet': 'streaming services': False taskcoat: 'jeans': 'hat': 'scarf': 'boots': 'socks': 'food': 'fun': 'clothes': 'travel': True taskcoffee: 'restaurant': 'travel': 'plan ticket': 'school': False 'restaurant',
Code a function that accepts
Accept a monthly budget value
A maximum expense value
A dictionary of expenses with the folllowing keysvalue pair
key expense name: string value
value expense price: intfloat 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
taskfood: 'fun': 'clothes': 'travel':
True
taskfood: 'books': 'internet': 'streaming services':
False 'internet',
taskfood: 'fun': 'clothes': 'travel': 'books': 'internet': 'streaming services':
False
taskcoat: 'jeans': 'hat': 'scarf': 'boots': 'socks': 'food': 'fun': 'clothes': 'travel':
True
taskcoffee: 'restaurant': 'travel': 'plan ticket': 'school':
False 'restaurant',
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started