Homework 4: Online Banking System | Introduction to Python Programming


Introduction to Python Programming
University of Pennsylvania

Homework 4: Online Banking System

This assignment is designed to give you practice writing code and applying lessons and topics for the current module.

This homework deals with the following topics:

  • File I/O

  • Dictionaries

The Assignment

In this assignment, you will implement an online banking system.  Users can sign-up with the system, log in to the system, change their password, and delete their account.  They can also update their bank account balance and transfer money to another user’s bank account.

You’ll implement functions related to File I/O and dictionaries.  The first two 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.

For example, we have defined an “import_and_create_bank” function for you (see below) which loads the “bank.txt” file and creates and returns a dictionary.  Read the docstring, which explains what the function is supposed to do.  Then write your code where it says “# TODO” to implement the function.  You’ll do this for each function in the program.

def import_and_create_bank(filename):
    This function is used to create a bank dictionary.  The given argument is the filename to load.
    bank = {}
    # TODO
    return bank

We’ll run a Python test script against your program to test whether each function implementation is correct and whether you have considered enough cases.  Examples of cases have been provided in the docstrings.

The main function has been completely implemented for you (see example snippet below).  Use it to run and interact with your program, and to see if your functions are working as expected.  Spend some time on testing.

def main():
    The main function is a skeleton for you to test if your overall programming is working.
    bank = import_and_create_bank("bank.txt")
    user_accounts, log_in = import_and_create_accounts("user.txt")


Open the Jupyter Notebook directly in Coursera (you will find it in the item following this reading). The Coursera lab also includes the user.txt and bank.txt data files. To complete the assignment, complete the provided Jupyter Notebook file, following the detailed instructions in each cell. Test your submission before submitting by following the instructions on the assignment page in Coursera. When you’re happy with your solutions, click the ‘Submit Assignment’ button in the top right. 


Points:  Each function is worth 1 point.

To get the solution contact (Not for Free) -


Post a Comment