Computer
Science
   Practical Record File
           (Session 2019-2020)
Submitted to:           Submitted by:
Mr. SPS Chand         Avram John Neroth
(PGT-CS)                 (Class XII B)
           Certificate
 This is to certify that the programs enlisted in this
   practical record file have been designed and
                      executed by
                Avram John Neroth
                  Of class XII Science,
           The Lawrence School, Lovedale
               For session 2019-2020
              Under the supervision of
                  Mr. SPS CHAND
             In Partial fulfillment for the
      C.B.S.E. Computer Science Examination
(Mr. SPS Chand)                   Mr. Prabakaran Nair
(PGT CS)                          Headmaster
                               Input Code
from pickle import load, dump
import datetime
import os
def autogen():
  x=101
  if os.path.isfile('bank.dat')==True:
    fp=open('bank.dat','rb')
    try:
      while True:
           a=load(fp)
           x+=1
    except EOFError:
       pass
  return x
class mainaf():
  def __init__(self):
    self.acname=''
    self.acno=0
    self.actype=''
    self.acdate=''
    self.acaddr1=''
    self.acaddr2=''
  self.accity=''
  self.bal=0
  self.pasw=''
  self.hint=''
def getdata(self):
  self.acname=input(' Enter your name: ')
  print()
  self.acno=autogen()
  print('Your account number: ',self.acno)
  print()
  self.actype=input(' Enter your account type: ')
  print()
  self.acdate=datetime.date.today()
  print ('Date:',self.acdate)
  print()
  self.acaddr1=input('Enter Address 1: ')
  print()
  self.acaddr2=input('Enter Address 2: ')
  print()
  self.accity=input('Enter City: ')
  print()
  self.bal=int(input('Enter opening balance: '))
  print()
  self.pasw=input('Enter your password: ')
  print()
  self.hint=self.pasw[::-1]
  print()
def dispd(self):
    print()
    print('Account number: ',self.acno,'\t','Name: ',self.acname,
        '\t','Account type: ',self.actype,'\t',
        'Balance: ',self.bal,"Date: ", self.acdate)
def addacc():
  a=mainaf()
  fp=open('bank.dat','ab')
  a.getdata()
  dump(a,fp)
  fp.flush()
  fp.close()
  print()
  print('Account has been successfully added.')
  print()
  print("-*"*62)
  print()
def dispacc():
  fp=open('bank.dat','rb')
  try:
    while True:
         a=load(fp)
         a.dispd()
  except EOFError:
    pass
  fp.close()
def delacc():
  fp1=open('bank.dat','rb')
  fp2=open('temp.dat','wb')
  ano=int(input('Enter account number to delete: '))
  print()
  try:
    while True:
         a=load(fp1)
         if a.acno==ano:
            fp2.flush()
         else:
            dump(a,fp2)
  except EOFError:
    pass
  fp1.close()
  fp2.close()
  os.remove('bank.dat')
  os.rename('temp.dat','bank.dat')
  print()
  print('      Account has been successfully deleted.   ')
  print()
  print("-*"*62)
  print()
def bankserv():
  while True:
    print()
    print('1. CREATE ACCOUNT')
    print()
    print('2. DISPLAY ACCOUNT')
    print()
    print('3. DELETE ACCOUNT')
    print()
    print('4. RETURN TO MAIN MENU')
    print()
    skey=int(input('ENTER YOUR CHOICE: '))
    print()
    if skey==1:
       addacc()
    if skey==2:
       dispacc()
    if skey==3:
       delacc()
    if skey==4:
       break
    print()
    print("-*"*62)
class trans():
  def __init__(self,na,no,ty,dt,wd,amo,mo):
     self.trname=na
     self.trno=no
     self.trtype=ty
     self.trdate=dt
     self.trwd=wd
     self.tramo=amo
     self.trmo=mo
  def dispt(self):
     print('Account Name: ',self.trname,'\t','Account Type: ',self.trtype)
     print()
     print('Date of Transaction: ',self.trdate,'\t','Transaction Type: ',
         self.trwd,'\t','Transaction Amount: ',self.tramo,'\t',
         'Transaction Method: ',self.trmo)
     print()
     print()
def transac():
  fp1=open('bank.dat','rb')
  fp2=open('temp.dat','wb')
  ano=int(input('Enter account number: '))
  try:
while True:
  a=load(fp1)
  if a.acno==ano:
    print('Hint:',a.hint)
    print()
    p=input('Enter Your Password:')
    print()
    if p==a.pasw:
      pass
    else:
      print('Sorry, Incorrect Password')
      print()
      break
    x=a.acname
    y=a.actype
    z=a.bal
    print(' Name: ',x)
    print()
    print(' Current balance: ',z)
    print()
    k=input(' Would you like to withdraw(w) or deposit(d) ?')
    print()
    q=int(input(' Enter amount: '))
    print()
    u=input('Enter mode of transaction,(cash or cheque):')
    if k=='w':
      a.bal-=q
         else:
           a.bal+=q
         print()
         print('            Transaction is complete.      ')
         print()
         print('New balance: ',a.bal)
         print()
         print("-*"*62)
         t=trans(x ,ano ,y ,datetime.date.today() ,k ,q
              ,u)
         fp=open('trans.dat','ab')
         dump(t,fp)
         fp.flush()
         fp.close()
         dump(a,fp2)
    else:
         dump(a,fp2)
except EOFError:
  pass
fp1.close()
fp2.close()
os.remove('bank.dat')
os.rename('temp.dat','bank.dat')
def current():
  fp1=open('bank.dat','rb')
  ano=int(input('Enter account number: '))
  print()
  try:
    while True:
         a=load(fp1)
         if a.acno==ano:
            print(' Name: ',a.acname,'\t',' Account type: ',a.actype,'\t',
                 ' Closing balance: ',a.bal)
         else:
            pass
  except EOFError:
    pass
  fp1.close()
def minis():
  fp1=open('trans.dat','rb')
  print()
  tno=int(input('Enter account number: '))
  print()
  try:
    while True:
         t=load(fp1)
         if t.trno==tno:
            t.dispt()
  except EOFError:
    pass
  fp1.close()
  fp1=open('bank.dat','rb')
  try:
    while True:
         a=load(fp1)
         if a.acno==tno:
           print()
           print('Closing balance',a.bal)
           print()
           print("-*"*62)
           print()
         else:
           pass
  except EOFError:
    pass
  fp1.close()
def mini():
  while True:
    print()
    print('1. CURRENT STATEMENT')
    print()
    print('2. MINI STATEMENT')
    print()
    key=int(input('ENTER YOUR CHOICE: '))
    print()
    if key==1:
       current()
       break
    if key==2:
       minis()
       break
    print()
    print("-*"*62)
    print()
def report():
  while True:
    print('1. ACCOUNT LIST')
    print()
    print('2. INDIVIDUAL ACCOUNT')
    print()
    print('3. RETURN')
    print()
    key=int(input('ENTER YOUR CHOICE:'))
print()
if key==1:
  dispacc()
if key==2:
  mini()
if key==3:
  break
print()
print("-*"*62)
print()
def menu():
  while True:
    print()
    print('MAIN MENU ')
    print()
    print('1. BANK SERVICES')
    print()
    print('2. TRANSACTION')
    print()
    print('3. REPORT')
    print()
    print('4. EXIT')
    print()
    skey=int(input('ENTER YOUR CHOICE: '))
    print()
    print("-*"*62)
    if skey==1:
       bankserv()
    if skey==2:
       transac()
    if skey==3:
       report()
    if skey==4:
       break
    print()
    print("-*"*62)
    print()
while True:
  print('                 WELCOME TO       ')
  print('                 _DUCK BANK_     ')
  print()
  print('1. MAIN MENU')
  print()
  print('2. EXIT')
  print()
  key=int(input('Enter your choice: '))
  print()
  print('-*'*62)
  if key==1:
    menu()
  if key==2:
    break
                                     Output
============ RESTART: D:\George 12 B C.S\duck bank ( FINAL) 3.py ============
                                        WELCOME TO
                                        _DUCK BANK_
1. MAIN MENU
2. EXIT
Enter your choice: 1
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
MAIN MENU
1. BANK SERVICES
2. TRANSACTION
3. REPORT
4. EXIT
ENTER YOUR CHOICE: 1
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. CREATE ACCOUNT
2. DISPLAY ACCOUNT
3. DELETE ACCOUNT
4. RETURN TO MAIN MENU
ENTER YOUR CHOICE: 1
Enter your name: George
Your account number: 101
Enter your account type: Savings
Date: 2019-10-19
Enter Address 1: House no: 3, The Lawrence School, Lovedale
Enter Address 2: Blue Lagoon Apartments, Race course Road, Coimbatore, Flat no: 3A
Enter City: Coimbatore
Enter opening balance: 400000
Enter your password: avram
Account has been successfully added.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. CREATE ACCOUNT
2. DISPLAY ACCOUNT
3. DELETE ACCOUNT
4. RETURN TO MAIN MENU
ENTER YOUR CHOICE: 1
Enter your name: Avram
Your account number: 102
Enter your account type: Savings
Date: 2019-10-19
Enter Address 1: Blue Lagoon Apartments, Race course Road, Coimbatore , Flat no:4B
Enter Address 2: Skyline Apartments, M.G. Road, Coimbatore, Flat no: 10F
Enter City: Coimbatore
Enter opening balance: 200000
Enter your password: ram
Account has been successfully added.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. CREATE ACCOUNT
2. DISPLAY ACCOUNT
3. DELETE ACCOUNT
4. RETURN TO MAIN MENU
ENTER YOUR CHOICE: 2
Account number: 101      Name: George            Account type: Savings Balance: 400000 Date: 2019-
10-19
Account number: 102      Name: Avram Account type: Savings Balance: 200000 Date: 2019-10-19
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. CREATE ACCOUNT
2. DISPLAY ACCOUNT
3. DELETE ACCOUNT
4. RETURN TO MAIN MENU
ENTER YOUR CHOICE: 3
Enter account number to delete: 102
     Account has been successfully deleted.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. CREATE ACCOUNT
2. DISPLAY ACCOUNT
3. DELETE ACCOUNT
4. RETURN TO MAIN MENU
ENTER YOUR CHOICE: 4
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
MAIN MENU
1. BANK SERVICES
2. TRANSACTION
3. REPORT
4. EXIT
ENTER YOUR CHOICE: 2
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
Enter account number: 101
Hint: marva
Enter Your Password: avram
 Name: George
Current balance: 400000
Would you like to withdraw(w) or deposit(d) ?w
Enter amount: 12000
Enter mode of transaction,(cash or cheque):Cash
                                         Transaction is complete.
New balance: 388000
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
MAIN MENU
1. BANK SERVICES
2. TRANSACTION
3. REPORT
4. EXIT
ENTER YOUR CHOICE: 3
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. ACCOUNT LIST
2. INDIVIDUAL ACCOUNT
3. RETURN
ENTER YOUR CHOICE:1
Account number: 101         Name: George         Account type: Savings     Balance: 388000 Date: 2019-
10-19
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. ACCOUNT LIST
2. INDIVIDUAL ACCOUNT
3. RETURN
ENTER YOUR CHOICE:2
1. CURRENT STATEMENT
2. MINI STATEMENT
ENTER YOUR CHOICE: 1
Enter account number: 101
Name: George             Account type: Savings            Closing balance: 388000
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. ACCOUNT LIST
2. INDIVIDUAL ACCOUNT
3. RETURN
ENTER YOUR CHOICE:2
1. CURRENT STATEMENT
2. MINI STATEMENT
ENTER YOUR CHOICE: 2
Enter account number: 101
Account Name: George             Account Type: Savings
Date of Transaction: 2019-10-19          Transaction Type: w     Transaction Amount: 12000
Transaction Method: Cash
Closing balance 388000
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
1. ACCOUNT LIST
2. INDIVIDUAL ACCOUNT
3. RETURN
ENTER YOUR CHOICE:3
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
MAIN MENU
1. BANK SERVICES
2. TRANSACTION
3. REPORT
4. EXIT
ENTER YOUR CHOICE: 4
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*
                WELCOME TO
                _DUCK BANK_
1. MAIN MENU
2. EXIT
Enter your choice: 2
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*