Question: Use python for online banking system, fill in missing code. Information for the code is in red. Youll implement functions related to File I/O and

Use python for online banking system, fill in missing code. Information for the code is in red. Youll implement functions related to File I/O and dictionaries. Both functions require you to import files and create dictionaries. User information will be imported from the users.txt file and account information will be imported from the bank.txt file. Take a look at the content in the different files. The remaining functions require you to use or modify the two dictionaries created from the files.

Each function has been defined for you, but without the code. See the docstring in each function for instructions on what the function is supposed to do and how to write the code. It should be clear enough. In some cases, we have provided hints to help you get started. Thank you

Use python for online banking system, fill in missing code. Information for

CODE:

import nose.tools as tools

def import_and_create_dictionary(filename):

d = {}

--------missing code------------------------

bank = import_and_create_dictionary("bank.txt")

tools.assert_false(len(bank) == 0) tools.assert_almost_equal(115.5, bank.get("Brandon")) tools.assert_almost_equal(128.87, bank.get("James")) tools.assert_is_none(bank.get("Joel")) tools.assert_is_none(bank.get("Luke")) tools.assert_almost_equal(bank.get("Sarah"), 827.43)

the code is in red. Youll implement functions related to File I/OCODE:

def signup(user_accounts, log_in, username, password):

--------------missing code-------------------------------------

This function is used to create a bank dictionary. The given argument is the filename to load. Every line in the file will look like key: value Key is a user's name and value is an amount to update the user's bank account with. The value should be a number, however, it is possible that there is no value or that the value is an invalid number. What you will do: - Try to make a dictionary from the contents of the file. If the key doesn't exist, create a new key:value pair. If the key does exist, increment its value with the amount. You should also handle cases when the value is invalid. If so, ignore that line and don't update the dictionary. - Finally, return the dictionary. Note: All of the users in the bank file are in the user account file. This function allows users to sign up. If both username and password meet the requirements, updates the username and the corresponding password in the user_ac and returns True. If the username and password fail to meet any one of the following requirements, returns False. The username already exists in the user accounts. The password must be at least 8 characters. - The password must contain at least one lowercase character. - The password must contain at least one uppercase character. - The password must contain at least one number. - The username & password cannot be the same. For example: - Calling signup(user_accounts, log_in, "Brandon", "123abcABCD") will return false - Calling signup(user accounts, log in, "BrandonK", "123ABCD") will return false - Calling signup(user accounts, log in, "BrandonK", "abcdABCD") will return False - Calling signup(user_accounts, log_in, "BrandonK", "123aABCD") will return True. Then calling signup(user_accounts, log_in, "BrandonK", "123aABCD") again will return false. Hint: Think about defining and using a separate valid(password) function that checks the validity of a given password. This will also come in handy when writing the change_password() function. This function is used to create a bank dictionary. The given argument is the filename to load. Every line in the file will look like key: value Key is a user's name and value is an amount to update the user's bank account with. The value should be a number, however, it is possible that there is no value or that the value is an invalid number. What you will do: - Try to make a dictionary from the contents of the file. If the key doesn't exist, create a new key:value pair. If the key does exist, increment its value with the amount. You should also handle cases when the value is invalid. If so, ignore that line and don't update the dictionary. - Finally, return the dictionary. Note: All of the users in the bank file are in the user account file. This function allows users to sign up. If both username and password meet the requirements, updates the username and the corresponding password in the user_ac and returns True. If the username and password fail to meet any one of the following requirements, returns False. The username already exists in the user accounts. The password must be at least 8 characters. - The password must contain at least one lowercase character. - The password must contain at least one uppercase character. - The password must contain at least one number. - The username & password cannot be the same. For example: - Calling signup(user_accounts, log_in, "Brandon", "123abcABCD") will return false - Calling signup(user accounts, log in, "BrandonK", "123ABCD") will return false - Calling signup(user accounts, log in, "BrandonK", "abcdABCD") will return False - Calling signup(user_accounts, log_in, "BrandonK", "123aABCD") will return True. Then calling signup(user_accounts, log_in, "BrandonK", "123aABCD") again will return false. Hint: Think about defining and using a separate valid(password) function that checks the validity of a given password. This will also come in handy when writing the change_password() function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!