Advertisement
Guest User

Untitled

a guest
Jan 31st, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. f= open("Passes.py", "a+")
  2. m=open("money.py","a+")
  3. passes= {}
  4. init={}
  5. initial=0
  6. import time
  7. wait=time.sleep(0.5)
  8. print "Welcome to the virtual banking system"
  9. wait
  10. user=raw_input("Would you like to create a new account? 'Y/N'").lower()
  11. if user== "y":
  12. new_user= raw_input("Create a username:")
  13. new_pass= raw_input("Create a password:")
  14. p= passes[new_user]= new_user + ":" + new_pass
  15. f.write("n"+p)
  16. ask=raw_input("Would you like to sign into your account? 'Y/N'").lower()
  17. if ask=="y":
  18. user_in=raw_input("Enter your username:")
  19. if user_in==new_user:
  20. pass_in=raw_input("Enter your password:")
  21. if pass_in==new_pass:
  22. running=True
  23. while running:
  24. print "Welcome to your account" + " " + new_user
  25. useropt=raw_input("Would you like to view your balance- enter 1, deposit money- enter 2 or withdraw money- enter 3:")
  26. if useropt=="1":
  27. print "Your balance is:", initial
  28. m.write("n"+str(initial))
  29. if useropt=="2":
  30. m.close()
  31. u=open("money.py","r+")
  32. amountdep= int(raw_input("How much money would you like to deposit?:"))
  33. initial+=amountdep
  34. print "Thanks. Your new balance is:", initial
  35. u.write(str(initial)+"n")
  36. if useropt=="3":
  37. m.close()
  38. r=open("money.py","r+")
  39. amountwith=int(raw_input("How much would you like to withdraw?:"))
  40. initial-=amountwith
  41. if initial>=0:
  42. print "Your balance is:", initial
  43. r.write(str(initial)+"n")
  44. else:
  45. print "Sorry, this amount cannot be withdrawn. Balance cannot be less than 0"
  46. cont = raw_input("Would you like to do another operation? 'Y/N'").lower()
  47. running = cont == "y"
  48. else:
  49. print "Password not valid"
  50.  
  51. else:
  52. print "Username does not exist"
  53.  
  54. else:
  55. print "Thanks for using the virtual bank."
  56.  
  57. else:
  58. user2=raw_input("Do you have an existing account? 'Y/N'").lower()
  59. if user2=="y":
  60. existing_user=raw_input("Enter your username:")
  61. exisitng_pass=raw_input("Enter your password:")
  62. for passwords in f:
  63. if passwords==existing_user+":"+exisitng_pass:
  64. run=True
  65. while run:
  66. print "Welcome to your account" + " " + existing_user
  67. with open("money.py", "r") as m:
  68. info= int(m.readline().strip())
  69. useropt2=raw_input("Would you like to view your balance- enter 1, deposit money- enter 2 or withdraw money- enter 3:")
  70. if useropt2=="1":
  71. print "Your balance is:", info
  72. if useropt2=="2":
  73. amountdep= int(raw_input("How much money would you like to deposit?:"))
  74. a=info+int(amountdep)
  75. print "Your new balance is:", a
  76. with open("money.py", "w") as m:
  77. m.write(str(a))
  78. if useropt2=="3":
  79. amountwith=int(raw_input("How much would you like to withdraw?:"))
  80. t=info-int(amountwith)
  81. if t>=0:
  82. print "Your balance is:", t
  83. with open("money.py", "w") as m:
  84. m.write(str(t))
  85. else:
  86. print "Sorry, this amount cannot be withdrawn. Balance cannot be less than 0"
  87. restart = raw_input("Would you like to do another operation? 'Y/N'").lower()
  88. run = restart == "y"
  89. else:
  90. print "Invalid username or password"
  91. else:
  92. print "Thanks for using the virtual bank."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement