Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import time
  2. score = 0
  3.  
  4. print("Welcome to the quiz!")
  5. time.sleep(1)
  6. print("In order to play, you have to register an account.")
  7. time.sleep(1)
  8. name = str(input("Please enter your full name: "))
  9. time.sleep(1) # Validates password
  10. for 8 characters long.
  11. while True:
  12. password = input("Please enter your account password(at least 8 characters): ")
  13. if len(password) < 8:
  14. print("Make sure your password is at least 8 letters.")
  15. else :
  16. print("Password is fine.")
  17. break
  18.  
  19. # Age validation for 11 and over only
  20. age = int(input("Please enter your age: "))
  21. if (age < 11):
  22. print("You have to be 11 or over to play the quiz.")
  23. exit()
  24. else :
  25. print("Your age is fine.")
  26.  
  27. YGrp = int(input("What year group are you in?(number only): "))
  28.  
  29. # Creates a username using first 3 letters of the full name and the user 's age.
  30. username = name[: 3] + str(age)
  31. filename = username + ".txt" # Details are stored in an external text file; Username, password, age and year group.
  32. file = open(filename, 'w')
  33. file.write("Username: " + username)
  34. file.write("nPassword: " + password)
  35. file.write("nAge: " + str(age))
  36. file.write("nYear Group: " + str(YGrp))
  37. file.close()
  38.  
  39. # Easy questions in an external file
  40. file = open("easyquestions.txt", 'w')
  41. file.write("What does CPU stand for?")
  42. file.write("na. Central Processor Unit")
  43. file.write("nb. Central Processing Unit")
  44. file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement