Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using python3 to solve the problem Part II: Credit Card Statements (4 points) Complete the statement ) function, which takes two arguments: a starting credit
Using python3 to solve the problem
Part II: Credit Card Statements (4 points) Complete the statement ) function, which takes two arguments: a starting credit card balance (a floating-point number) and a list of transactions (note that the second argument is actually a list of lists; each element is a 2-element list whose first item is a string indicating the type of transaction and whose second item is a number to apply to the current account balance according to the rules below). The function returns the final balance after every transaction has been applied. . A "credit" transaction subtracts the associated value from the current balance . A "debit" transaction adds the associated value to the current balance An "interest" transaction multiplies the current balance by (1 plus its associated value) (for example, .04 represents a 4% interest rate) Any other transaction label is ignored For example, suppose we have a starting balance of 105.92 and the following list of transactions: [["debit", 65.01], ["debit", 14.87], ["deposit", 61.30], ["interest", .16], ["credit" 29.45]] We would perform the following sequence of adjustments 1. The first transaction is ["debit", 65.01]. Its first element is "debit", so we add 65.01 to our balance to get 170.93 2. The second transaction is ["debit", 14.87], so we add 14.87 to our current balance to get 185.80 3. The third transaction is ["deposit", 61.30]. "deposit" isn't a recognized keyword, so we do nothing 4. The fourth transaction is ["interest",.16], so we multiply the current balance by 1.16 (1 plus the second list item) to get 215.528 5. The fifth transaction is ["credit", 29.45], so we subtract 29.45 from the current balance to get a final answer of 186.078 (don't worry about rounding the result to 2 decimal places) Examples: Function Call statement (219.73, [["credit", 102.88, ["credit", 468.641, ["1nterest", 0.23], "debit", 128.48]]) statement (40.22, [["debit", 474.23], ["interest", 0.32], ["debit, 452.68] "debit", 158.95], "interest", 0.34, ["Credit", 34.47]]) statement (1220.61, ["credit", 393.09], ["credit", 62.42, ["credit", 284.841, "payment", 88.19], "debit", 153.12], ["payment", 122.98], "credit", 69.1], "1nterest", 0.06]]) Return Value -304.22169999999994 1695.0733600000003 598.1368000000001Step 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