important class 11 python dictionary program accepts transaction details and displays balance

In this article, we are going to discuss a class 11 python dictionary program that accepts transaction details in dictionary form and displays the balance accordingly. Let us begin!

Class 11 Python Dictionary Program – Bank transaction and update balance

The complete definition of a program is as follows:

Write a program to accept transaction details in dictionary form and display updated balance.

Let us begin the process for the program.

Variables Required for Input and Output

So as per the questions given, we need the following variables:

  1. Balance
  2. A dictionary accepts the transaction details where transaction type (D for Debit and C for Credit) as a key and amount as a value
  3. i for traversing a dictionary in for loop


  1. Declare a variable for initial balance. In our program its bal = 50000
  2. Print the initial balance
  3. Prompt for transaction detail using eval(inut())
  4. Take a for loop to traverse a dictionary
  5. Now apply if condition for the appropriate function as per the transaction
  6. Check the key, if it is ‘D’ deduct value from bal
  7. If the key is ‘C’ add the value into bal
  8. Print the updated closing balance


Observe the code for the program:

'''Write a program to accept transaction details
in dictionary form and display balance.'''
#For example:
#Enter transaction:{'D':5000}
#Output should be:
'''Initial Balance - 50000
Closing Balance after transaction - 45000'''

#Step 1 Initiate Balance

#Input transaction details
tr=eval(input("Enter transaction detail:"))

#Printing Initial Balance
print("Initial Balance - ",bal)

#Traversing Dictionary to perform the transaction
for i in tr:
  #Checking if transaction for debit and update balance
  if i=='D':
    #Update balance
  #Checking if transaction for credit and update balance
  if i=='C':

#Printing closing balance
print("Closing Balance After transaction - ",bal)

Download Code

Follow this link to download class 11 python dictionary program bank account transaction.

Download Python Code


class 11 python dictionary program bank transaction

Watch this video for practical demo:

I hope this program helps you to understand the concept dictionary and how to work with a dictionary in python. If you have any doubts or queries or want to share your views about our website you are welcome to share.

Your views/suggestions/feedbacks related to this article class 11 python dictionary program are also welcome. Feel free to share in the comment section.

Thank you for reading this article.

For more programs for class 11, follow this link:

Class 11 Python Programs

Leave a Reply