Python Code with Explanation:
# get the monthly budget from the user
budget =float(input('Please enter your monthly budget! '))
expense = 0
count = 0
# run a while loop to keep getting input unless user enters -1 to quit
while count >= 0:
count = float(input('Please enter your expenses or enter -1 to quit: '))
if count != -1:
# keep a running total of expenses
expense += count
# when the loop terminates, calculate the monthly balance
balance = budget - expense
# using if elif conditions check for under or over budget
if balance < 0:
print('You are under budget this month! by an amount of: ', balance*-1)
elif balance > 0:
print('You are over budget this month! by an amount of: ', balance)
else:
print('Your budget and expenses are equal this month!')
Output:
Please refer to the attached screenshots!