5. calculate_new_balance Given a starting balance (a number), and a list of transaction tuples, calculate the final balance for an account. Transaction tuples are of the shape ("description", amount, "withdrawal") , or ("description", amount, "deposit"). The last entry in the tuple will be either "withdrawal" or "deposit". Every withdrawal decreases the balance of the account by the specified amount, and every deposit increases the balance. The return value is the new account balance, as a number. (which could be negative)

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 4.4CP
icon
Related questions
icon
Concept explainers
Question
5. calculate_new_balance
Given a starting balance (a number), and a list of
transaction tuples, calculate the final balance for an
account. Transaction tuples are of the shape
("description", amount, "withdrawal") , or ("description",
amount, "deposit"). The last entry in the tuple will be
either "withdrawal" or "deposit". Every withdrawal
decreases the balance of the account by the specified
amount, and every deposit increases the balance. The
return value is the new account balance, as a number.
(which could be negative)
Sample calls should look like:
>>> calculate_new_balance(100, [("payday", 20,
"deposit"), ("new shoes", 50, "withdrawal"),
("illicit winnings", 200, "deposit")])
270
>>> calculate_new_balance (100, [])
100
Transcribed Image Text:5. calculate_new_balance Given a starting balance (a number), and a list of transaction tuples, calculate the final balance for an account. Transaction tuples are of the shape ("description", amount, "withdrawal") , or ("description", amount, "deposit"). The last entry in the tuple will be either "withdrawal" or "deposit". Every withdrawal decreases the balance of the account by the specified amount, and every deposit increases the balance. The return value is the new account balance, as a number. (which could be negative) Sample calls should look like: >>> calculate_new_balance(100, [("payday", 20, "deposit"), ("new shoes", 50, "withdrawal"), ("illicit winnings", 200, "deposit")]) 270 >>> calculate_new_balance (100, []) 100
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage