Advertisement
blee255

Untitled

Mar 21st, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import time
  2. import random
  3. import os
  4.  
  5. #Username and Password
  6.  
  7.  
  8.  
  9. #Setting an error variable
  10.  
  11. error = 0
  12. running = True
  13.  
  14. #Reading a username and password file
  15.  
  16. username = open("username.txt", "r")
  17. usr_read = username.read()
  18. username.close()
  19.  
  20. password = open("password.txt", "r")
  21. psw_read = password.read()
  22. password.close()
  23.  
  24. #Checking in username and password match
  25.  
  26. usr_user = input("Username: ")
  27. if usr_user == usr_read:
  28. pass
  29. else:
  30. error = 1
  31.  
  32. usr_pass = input("Password: ")
  33.  
  34. if usr_pass == psw_read:
  35. pass
  36. else:
  37. error = 1
  38.  
  39. if error == 1:
  40. print("error", random.randrange(1, 102))
  41. time.sleep(1)
  42. quit()
  43. else:
  44. pass
  45.  
  46. #Once in gives various options to the user in what they want to do
  47.  
  48. while running:
  49.  
  50. print("What would you like me to check or would you want me to change username and password? Type user to change usr and pass")
  51.  
  52. cmd = input("//")
  53. lines = []
  54. #username and password credit to WindleSR https://www.youtube.com/watch?v=ozFu-xxl2Bs
  55.  
  56. if cmd == "user":
  57. print("Fill in the following.")
  58. new_usr = input("New Username: ")
  59. newusr = open("username.txt", "w")
  60. newusr.write(new_usr)
  61. newusr.close()
  62.  
  63.  
  64. new_psw = input("New Password: ")
  65. newpsw = open("password.txt", "w")
  66. newpsw.write(new_psw)
  67. newpsw.close()
  68.  
  69. if cmd == "quit":
  70. time.sleep(1)
  71. running = False
  72.  
  73. #Ask to check
  74.  
  75. if cmd == "homework":
  76. print("What will you want me to change: check dates, change dates, or view assignments?")
  77. choice = input("/")
  78. if choice == "check dates":
  79. with open('homework.txt', 'rt') as homework: #creating an array and inputting lines of the txt file
  80. for line in homework:
  81. lines.append(line)
  82. print(line[0])
  83. print("There you go")
  84. else:
  85. print("Sorry I do not recognize what you are saying")
  86. time.sleep(1)
  87. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement