Advertisement
sanpai

Command Line application through python

Oct 29th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. #Bank management system
  2.  
  3. import getpass
  4. import sys
  5.  
  6. User_Db = {'sanpai':'Admin123','anabharat':'Admin1234'}
  7. count = 0
  8.  
  9. def logon(User_Db):
  10.  
  11. u_name=input("Enter the username : ")
  12. print("\n")
  13. p_word=getpass.getpass("Enter Password : ")
  14. print("\n")
  15.  
  16. return User_Db.get(u_name,None) == p_word
  17. # print(u_name)
  18. # print (p_word)
  19.  
  20.  
  21. for r in range(20):
  22. print("*",end=" ")
  23.  
  24. print("\n")
  25. print("\t WELCOME TO BMS \t",end = " ")
  26.  
  27. print("\n")
  28. for r in range(20):
  29. print("*",end=" ")
  30.  
  31. print("\n")
  32.  
  33. for i in range(3):
  34. if logon(User_Db):
  35. print ("Authentication Successful ...")
  36. print ("\n")
  37. break
  38. else:
  39. if count == 2:
  40. print ("Account Locked Contact Admin ")
  41. print("\n")
  42. sys.exit()
  43. else:
  44. print ("Authentication failure please relogin ")
  45. print("\n")
  46. count+=1
  47.  
  48.  
  49. for r in range(20):
  50. print("*",end=" ")
  51.  
  52. print("\n")
  53.  
  54. while True:
  55.  
  56. print("1. ACCOUNT ")
  57. print("2. TRANSCATIONS ")
  58. print("3. REPORTS ")
  59. print("4. EXIT ")
  60.  
  61. print("\n")
  62.  
  63. try:
  64. choice=int(input("Enter Your choice : "))
  65. except ValueError:
  66. print("Enter a choice between 1 and 4")
  67.  
  68.  
  69. if choice == 1:
  70. while True:
  71.  
  72. print("1. Add Account")
  73. print("2. Update Account ")
  74. print("3. Delete Account ")
  75. print("4. Goto Main Menu ")
  76. print("5. Exit ")
  77.  
  78. try:
  79. choice=int(input("Enter Your choice : "))
  80. except ValueError:
  81. print("Enter a choice between 1 and 5")
  82.  
  83. if choice == 1:
  84. try:
  85. fp = open("Accounts.txt","a")
  86. except IOError:
  87. print("File error , try again")
  88.  
  89. Name = input("Enter your name : ")
  90. Mob_num = input ("Enter Mobile number : ")
  91.  
  92. fp.write('%s \t\t %s \t\t %d \t\n'%(Name,Mob_num,0))
  93.  
  94. print("account added succesfully ,maintain an minimum balance of INR 3000")
  95. fp.close()
  96.  
  97. elif choice == 2:
  98. print("To be done ")
  99.  
  100. elif choice == 3:
  101. print("To be done ")
  102.  
  103. elif choice == 4:
  104. print("To be done ")
  105.  
  106. elif choice == 5:
  107. sys.exit()
  108. else:
  109. print("Enter a choice between 1 and 5")
  110.  
  111. elif choice == 2:
  112. print("1. Deposit")
  113. print("2. Withdraw ")
  114. print("3. Goto Main Menu ")
  115. print("4. Exit")
  116.  
  117. try:
  118. ch=int(input("Enter Your choice : "))
  119. except ValueError:
  120. print("Enter a choice between 1 and 4")
  121. elif choice == 3:
  122. print("Reports")
  123.  
  124. elif choice == 4:
  125. sys.exit()
  126.  
  127. else:
  128. print("Enter a choice between 1 and 4")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement