Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. import random
  2.  
  3. balance = "%.2f" % round(random.uniform(1,1000),2)
  4.  
  5.  
  6. save = 0
  7. attempt = 1
  8. database = []
  9. def getPassword(x):
  10. loop = 1
  11. while loop == 1:
  12. global attempt
  13. while attempt == 1:
  14. password = input("Enter Password: ")
  15. while len(password) > 8 or len(password) < 6:
  16. password = input("Error. Password must be 6-8 characters. Try again: ")
  17. else:
  18. attempt = attempt + 1
  19. while attempt == 2:
  20. secondPassword = input("Re-Enter Password: ")
  21. if secondPassword == password:
  22. print("Registration sucessful.")
  23. attempt = 1
  24. return password
  25. else:
  26. print("Error. Passwords do not match.")
  27. attempt = 1
  28.  
  29. def changePassword():
  30. global save
  31. global database
  32. looping = 1
  33. success = 0
  34. oldpword = input("\nPlease enter your old password: ")
  35. while looping == 1:
  36. if oldpword == database[save][1]:
  37. newpword = input("Please enter your new password: ")
  38. redopword = input("Please enter your password again: ")
  39. while newpword != redopword:
  40. redopword = input("Passwords do not match. Try again:")
  41. database[save][1] = redopword
  42. success = 1
  43. break
  44. looping -= 1
  45. while oldpword != database[save][1] and success != 1:
  46. oldpword = input("Incorrect password. Try again: ")
  47.  
  48. def getUsername():
  49. loop = 1
  50. global database
  51. while loop == 1:
  52. username = input("\nEnter your Username: ")
  53. if len(database) == 1:
  54. while username == database[0][0]:
  55. username = input("Username taken. Try again: ")
  56. else:
  57. for counter in range(len(database)):
  58. while username == database[counter][0]:
  59. username = input("Username taken. Try again: ")
  60. return username
  61.  
  62. def getMaster():
  63. global database
  64. username = input("Enter your Master Username: ")
  65. password = input("Enter your Master Password: ")
  66. database.append([username,password,"%.2f" % round(random.uniform(1,1000),2)])
  67.  
  68. def Login():
  69. global save
  70. success = 0
  71. username = input("\nPlease enter your Username: ")
  72. for counter in range(0,len(database)):
  73. if username == database[counter][0]:
  74. save = counter
  75. success = 1
  76. if username != database[counter][0] and success != 1:
  77. print("Username not found.")
  78. if success == 1:
  79. password = input("Please enter your Password: ")
  80. logged = 0
  81. while logged == 0:
  82. if password == database[save][1]:
  83. print("\nSucessful login.")
  84. logged += 1
  85. return logged
  86.  
  87. else:
  88. while password != database[save][1]:
  89. password = input("Incorrect password. Try again: ")
  90.  
  91.  
  92. def LoggedIn():
  93. global masterloop
  94. global database
  95. global save
  96. balance = database[save][2]
  97. loop = 1
  98. while loop == 1:
  99. print("\nWhich of the following would you like to do?")
  100. print("\nA) View current balance")
  101. print("B) Deposit cash")
  102. print("C) Withdraw cash")
  103. print("D) Change your password")
  104. choice = input("").lower()
  105.  
  106. if choice == "a":
  107. print("\nYour current account balance is:")
  108. print(" £"+str(balance))
  109. elif choice == "b":
  110. depamount = float(input("\nHow much would you like to deposit? "))
  111. print("Processing..")
  112. balance = float(balance) + depamount
  113. print("\nYour new current account balance is:")
  114. print(" £"+str(balance))
  115.  
  116. elif choice == "c":
  117. withamount = float(input("\nHow much would you like to withdraw? "))
  118. print("Processing..")
  119. while withamount > float(balance):
  120. print("\nYou do not have enough money.")
  121. print("Your current account balance is:")
  122. print(" £"+str(balance))
  123. withamount = float(input("\nPlease enter how much you would like to withdraw now: "))
  124. balance = float(balance) - withamount
  125. print("Your new current account balance is:")
  126. print(" £"+str(balance))
  127. elif choice == "d":
  128. changePassword()
  129. continuing = input("\nWould you like to continue? ").lower()
  130. if continuing == "yes":
  131. continue
  132. else:
  133. break
  134.  
  135.  
  136. getMaster()
  137. masterloop = 1
  138. while masterloop == 1:
  139. choice = input("\nWould you like to login, create a new account or exit?").lower()
  140. if choice == "login":
  141. logged = Login()
  142. if logged == 1:
  143. LoggedIn()
  144. elif choice == "exit":
  145. masterloop -= 1
  146. else:
  147. username = getUsername()
  148. password = getPassword(attempt)
  149. database.append([username,password,"%.2f" % round(random.uniform(1,1000),2)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement