In Python IDLE: How would I write a function for the problem in the attached image? >> piggyBank(['D', 'p', 'Q', 'Q', 'D', 'P', 'p'])({'Q': 2, 'D': 2, 'N': 0, 'p': 3}, 73)3>>> piggyBank (['D', 'D',...

In Python IDLE: How would I write a function for the problem in the attached image?piggyBank<br>Write a function piggyBank that accepts a sequence of >> piggyBank(['D', 'p', 'Q', 'Q', 'D', 'P', 'p']) ({'Q': 2, 'D': 2, 'N': 0, 'p': 3}, 73) 3 >>> piggyBank (['D', 'D', 'N', 'N', 'N']) 4 ({'Q': 0, 'D': 2, 'N': 3, 'P': 0}, 35) 5 >>> piggyBank(['p', 'D', 'N', 'P', 'N', 'N', 'N', 'Q', 'D', 'p', 'Q', 'Q', (ניD' 6. ({'Q': 3, 'D': 3, 'N': 4, 'p': 3}, 128) 7 >>> piggyBank (['D', 'p', 'Q', 'Q', 'D', 'p', 'p'])==({'Q': 2, 'D': 2, 'N': 0, 'p': 3}, 73) 8 True "/>
Extracted text: piggyBank Write a function piggyBank that accepts a sequence of "coins" and returns counts of the coins and the total value of the bank. • the coins will be given by a list of single characters, each one of 'Q', 'D','N',P', representing quarter, dime, nickel, penny • the function returns a tuple with two items: 1. a dictionary with counts of each denomination. They should always be listed in the order 'Q','D','N',P' 2. the total value in whole cents of the amount in the bank Sample usage: >>> piggyBank(['D', 'p', 'Q', 'Q', 'D', 'P', 'p']) ({'Q': 2, 'D': 2, 'N': 0, 'p': 3}, 73) 3 >>> piggyBank (['D', 'D', 'N', 'N', 'N']) 4 ({'Q': 0, 'D': 2, 'N': 3, 'P': 0}, 35) 5 >>> piggyBank(['p', 'D', 'N', 'P', 'N', 'N', 'N', 'Q', 'D', 'p', 'Q', 'Q', (ניD' 6. ({'Q': 3, 'D': 3, 'N': 4, 'p': 3}, 128) 7 >>> piggyBank (['D', 'p', 'Q', 'Q', 'D', 'p', 'p'])==({'Q': 2, 'D': 2, 'N': 0, 'p': 3}, 73) 8 True

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here