Answered step by step
Verified Expert Solution
Link Copied!

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions