Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. import time
  2. import string
  3. import random
  4. import sys
  5. import os
  6. # # # # # # #
  7. # Functions #
  8. # # # # # # #
  9. def levels():
  10. loggedin()
  11. def generator():
  12. import string
  13. import random
  14. import time
  15.  
  16. possibleCharacters = string.ascii_lowercase + string.digits + string.ascii_uppercase + ' .,!?;:'
  17.  
  18. target = input("Enter your target text: ")
  19. attemptThis = ''.join(random.choice(possibleCharacters) for i in range(len(target)))
  20. attemptNext = ''
  21.  
  22. completed = False
  23.  
  24. generation = 0
  25.  
  26. while completed == False:
  27. print(attemptThis)
  28. attemptNext = ''
  29. completed = True
  30. for i in range(len(target)):
  31. if attemptThis[i] != target[i]:
  32. completed = False
  33. attemptNext += random.choice(possibleCharacters)
  34. else:
  35. attemptNext += target[i]
  36. generation += 1
  37. attemptThis = attemptNext
  38. time.sleep(0.02)
  39.  
  40. print("Target matched! That took " + str(generation) + " generation(s)")
  41. end=input("Type 1 to run again or 0 To Return home: ")
  42. if end=="0":
  43. loggedin()
  44. else:
  45. generator()
  46. def calc():
  47. print("Welcome to the calculator")
  48. print("0.Return Home")
  49. print("1.Add")
  50. print("2.Subtract")
  51. print("3.Mutiply")
  52. print("4.Divide")
  53. main=input("Choice: ")
  54. if main=="0":
  55. loggedin()
  56. if main=="1":
  57. one=input("One: ")
  58. two=input("Two: ")
  59. total= float(one) + float(two)
  60. print(total)
  61. close=input("Press Enter To Continue")
  62. calc()
  63. if main=="2":
  64. one=input("One: ")
  65. two=input("Two: ")
  66. total= float(one) - float(two)
  67. print(total)
  68. close=input("Press Enter To Continue")
  69. calc()
  70. if main=="3":
  71. one=input("One: ")
  72. two=input("Two: ")
  73. total= float(one) * float(two)
  74. print(total)
  75. close=input("Press Enter To Continue")
  76. calc()
  77. if main=="4":
  78. one=input("One: ")
  79. two=input("Two: ")
  80. total= float(one) / float(two)
  81. print(total)
  82. close=input("Press Enter To Continue")
  83. calc()
  84. else:
  85. calc()
  86. # # # # # # #
  87. # User Area #
  88. # # # # # # #
  89. def loggedin():
  90. time.sleep(1)
  91. print (" "*2000)
  92. print("Options are listed below type one of them in to continue")
  93. print("0.Logout")
  94. print("1.Change Your Password")
  95. print("2.Use A Calculator")
  96. print("3.Text Generator")
  97. print("4.Levels")
  98. main=input("Choice: ")
  99. if main=="0":
  100. home1()
  101. if main=="1":
  102. password()
  103. if main=="2":
  104. calc()
  105. if main=="3":
  106. generator()
  107. if main=="4":
  108. levels()
  109. else:
  110. loggedin()
  111. # # # # # # # # #
  112. # Admin #
  113. # # # # # # # # #
  114. def adminlogin():
  115. print("Admin Control Panel")
  116. username=input("Username: ")
  117. password=input("Password: ")
  118. if username=="dan":
  119. if password=="dan":
  120. print("Logged In")
  121. print(" "*2000)
  122. adminhome()
  123. else:
  124. print("Login Failed, Returning Home")
  125. home1()
  126. else:
  127. print("Login Failed, Returning Home")
  128. home1()
  129. def tempadminhome():
  130. adminhome()
  131. def adminhome():
  132. print("Options are listed below type one of them in to continue")
  133. print("0.Logout")
  134. print("1.Change a users login details")
  135. print("2.Delete a user from the system")
  136. main=input("Choice: ")
  137. if main=="1":
  138. adminpassword()
  139. if main=="2":
  140. deleteuser()
  141. if main=="0":
  142. home1()
  143. else:
  144. tempadminhome()
  145. def deleteuser():
  146. print("Please enter the username of the user to delete enter '1' to return home")
  147. user=input("Username: ")
  148. if user=="1":
  149. print("\n")
  150. adminhome()
  151. else:
  152. try:
  153. os.remove((user) + (".txt"))
  154. print((user) + (" Removed from the system returning Home\n"))
  155. adminhome()
  156. except IOError:
  157. print("User Doesn't exist in the system, Returning Home\n")
  158. adminhome()
  159. def adminpassword():
  160. print("Enter the users username and desired password, If the user doesn't exist one will be created")
  161. username=input("Username: ")
  162. password=input("Password: ")
  163. f = open((username) + '.txt','w+')
  164. f.write(("-= Info =- \n") + (username) + ("\n") + (password))
  165. f.close()
  166. adminhome()
  167. # # # # # # # # #
  168. # AUTH #
  169. # # # # # # # # #
  170. def returnpasssword():
  171. password()
  172. def password():
  173. print("Please Relogin before chaning your password, type '1' to return home")
  174. username=input("Username: ")
  175. time.sleep(0.10)
  176. if username=="1":
  177. loggedin()
  178. else:
  179. password=input("Password: ")
  180. try:
  181. f = open((username) + '.txt','r')
  182. f = f.readlines()
  183. a = f[1]
  184. b = ((username) + ("\n"))
  185. time.sleep(0.10)
  186. if a==b:
  187. a = f[2]
  188. b = (password)
  189. time.sleep(0.10)
  190. if a==b:
  191. time.sleep(0.10)
  192. print("Please enter your new password")
  193. newpassword=input("Password: ")
  194. f = open((username) + '.txt','w+')
  195. f.write(("-= Info =- \n") + (username) + ("\n") + (newpassword))
  196. f.close()
  197. print(("Your new details are the following:\n") + ("Username: ") + (username) + ("\nPassword: ") + (newpassword))
  198. time.sleep(2)
  199. loggedin()
  200. else:
  201. print("Username Or Password Incorrect!")
  202. returnpasssword()
  203. else:
  204. print("Username Or Password Incorrect!")
  205. returnpasssword()
  206. except IOError:
  207. print("Username Or Password Incorrect!")
  208. returnpasssword()
  209. def login():
  210. username=input("Username: ")
  211. time.sleep(0.10)
  212. password=input("Password: ")
  213. try:
  214. f = open((username) + '.txt','r')
  215. f = f.readlines()
  216. a = f[1]
  217. b = ((username) + ("\n"))
  218. time.sleep(0.10)
  219. if a==b:
  220. a = f[2]
  221. b = (password)
  222. time.sleep(0.10)
  223. if a==b:
  224. time.sleep(0.10)
  225. print("Logged in")
  226. print("Sending you to Home")
  227. time.sleep(0.25)
  228. loggedin()
  229. else:
  230. print("Username Or Password Incorrect!")
  231. home1()
  232. else:
  233. print("Username Or Password Incorrect!")
  234. home1()
  235. except IOError:
  236. print("Username Or Password Incorrect!")
  237. home1()
  238. def create():
  239. username=input("Username: ")
  240. password=input("Password: ")
  241. try:
  242. f = open((username) + '.txt','r')
  243. time.sleep(0.10)
  244. f = f.readlines()
  245. a = f[0]
  246. b = ("-= Info =- \n")
  247. time.sleep(0.10)
  248. if a==b:
  249. print("Username Already Exists")
  250. else:
  251. home1()
  252. except IOError:
  253. f = open((username) + '.txt','w+')
  254. f.write(("-= Info =- \n") + (username) + ("\n") + (password))
  255. f.close()
  256. print(("Your Login Details Are:\nUsername: ") + (username) + ("\nPassword: ") + (password) + ("\nYou have 5 Seconds To Write These Down"))
  257. time.sleep(5)
  258. print (" "*2000)
  259. home1()
  260. # # # # # # # # #
  261. # Home #
  262. # # # # # # # # #
  263. def temphome():
  264. home1()
  265. def home1():
  266. home1=input("Would you like to 'Login' or 'Create' a new account?: ")
  267. home1 = home1.lower()
  268. if home1=="login":
  269. login()
  270. if home1=="create":
  271. create()
  272. if home1=="admin":
  273. adminlogin()
  274. else:
  275. start=input("Press Any Key To Return Home")
  276. temphome()
  277. # # # # # # # #
  278. # Main Centre #
  279. # # # # # # # #
  280. home1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement