Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 (6.5 pts.). Write a Python script that reads in names and corresponding bank balances (integers, without a $ or commas) and makes a dictionary

1 (6.5 pts.). Write a Python script that reads in names and corresponding bank balances (integers, without a $ or commas) and makes a dictionary of the associations. You can prompt the user first for how many name-income pairs (s)he wants to enter. Use int(input()) for input. After constructing the initial balances, repeatedly do the following: Prompt for a transaction, using a code number, for each bank customer: a deposit (code 1), a withdrawal (code 2), or no transaction (code 0). Update the dictionary of bank balances and output the updated customer-balance associations. Make a dictionary of the transactions where the keys are the same as for the balance dictionary (names of customers); positive values represent deposits, negative values represent withdrawals, and a zero represents no transaction. Maintain a list of the transaction dictionaries (one for each iteration). When the loop exits, output the current balances and the list of transactions in a well-formatted table. This could be implemented with recursion as well as with a loop. Use type hinting in annotations so that Mypy may catch infelicities. Use the special types defined in the typing module and include an assertion specifying that the integer code for the transaction type is between 0 and 2 (inclusive).

image text in transcribedimage text in transcribed

Example run Number of accounts: 3 Name: Ed Initial balance: 3.50 Name: Al Initial balance: 6.50 Name: sue Initial balance: 7.75 Processing Ed Transaction type: 0. Nothing 1. Deposit 2. Withdraw : 2 Amount: 4.00 Processing sue Transaction type: 0 . Nothing 1. Deposit 2. Withdraw : 1 Amount: 2.00 Processing Al Transaction type: 0. Nothing 1. Deposit 2. Withdraw :2 Amount: 8.00 Current Balances Ed$0.50Sue$9.75Al$1.50 0 to exit, any other key to continue: 1 Processing Ed Transaction type: 0. Nothing 1. Deposit 2. MLthdiray : 1 Ausuant: 3.50 Wreeessing Sue Franazatioe type: 0 . Mothing 1. Depasit 2. ML tharay : 0 Wrecessing Al Frasaiaties type: 0 . Bething 1. Depasit 2. ML tharay : 1 Ausent: 1.00 Currest Balabees Ba83.008.0Bl89.7580.50 0 to exit, aay ather key to aeatinue: 1 Wreeessing Ea Fraseadetios type: 0 . Bething 1. Depasit 2. ML tharay : 0 Wreeessing sue Fraseadetios type: 0. Mething 1. Depasit 2. ML thdray : 0 Wreeessing Al Fransaxtice type: 0 . Bething 1. Depadit 2. ML thdray : 1 Ausunt: 3.25 Currest Balabees Bu83.00sue89.75Bl82.75 0 to exit, any ather key to aobtinuet 0

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions