Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. FUNCTIONS
  2. """
  3. -------------------------------------------------------
  4. credentials.py
  5. all functions needed for a14
  6. -------------------------------------------------------
  7. Author: Ralph Suyat
  8. ID: 160516270
  9. Email: suya6270@mylaurier.ca
  10. Section B
  11. __updated__ = "2016-11-14"
  12. -------------------------------------------------------
  13. """
  14.  
  15.  
  16. def create_mls(first_name, last_name):
  17. """
  18. -------------------------------------------------------
  19. Creates username of user for MLS
  20. use: user = create_mls(first_name, last_name)
  21. -------------------------------------------------------
  22. Preconditions:
  23. first_name - the users inputed first name (str)
  24. last_name - the users inputed last name (str)
  25. Postconditions:
  26. return
  27. user - the username for MLS using the first and last name
  28. -------------------------------------------------------
  29. """
  30. user = ""
  31. user += first_name[0:1].lower()
  32. for char in last_name:
  33. if char.isalpha():
  34. user += char.lower()
  35.  
  36. return user
  37.  
  38.  
  39. def create_login(name):
  40. """
  41. -------------------------------------------------------
  42. Creates login of user for MLS
  43. use: login = create_login(name)
  44. -------------------------------------------------------
  45. Preconditions:
  46. name - the users inputed last name (str)
  47. Postconditions:
  48. return
  49. user - the login for MLS using the last name and student id
  50. -------------------------------------------------------
  51. """
  52. user = ""
  53. beginning = name[:4]
  54. last = name[-4:]
  55. for char in beginning:
  56. if (char.isalpha()):
  57. user += char
  58. else:
  59. user += "x"
  60. for char in last:
  61. user += char
  62. return user.lower()
  63.  
  64.  
  65. def create_pass(phrase):
  66. """
  67. -------------------------------------------------------
  68. Creates password for user for MLS
  69. use: login = create_pass(phrase)
  70. -------------------------------------------------------
  71. Preconditions:
  72. phrase - users choice of sentence (str)
  73. Postconditions:
  74. return
  75. password - the password for MLS
  76. -------------------------------------------------------
  77. """
  78. password = ""
  79. words = phrase.split(" ")
  80. for j in range(0, len(words)):
  81. password += get_alnum(words[j])
  82. return password
  83.  
  84.  
  85. def get_alnum(word):
  86. """
  87. -------------------------------------------------------
  88. Retrieves first valid char in the string and is used in the pass creation
  89. use: get_alnum(word)
  90. -------------------------------------------------------
  91. Preconditions:
  92. word - the users inputed phrase (str)
  93. Postconditions:
  94. return
  95. word - first valid char in the string
  96. -------------------------------------------------------
  97. """
  98. for i in range(0, len(word)):
  99. if word[i].isalnum():
  100. return word[i]
  101.  
  102. Q1 MAIN
  103. """
  104. -------------------------------------------------------
  105. q1.py
  106. creates the users username
  107. -------------------------------------------------------
  108. Author: Ralph Suyat
  109. ID: 160516270
  110. Email: Suya6270@mylaurier.ca
  111. Section: B
  112. __updated__ = "2016-11-14"
  113. -------------------------------------------------------
  114. """
  115. for i in range(0, 6):
  116. from credentials import create_mls
  117. first_name = input("What is your first name? ")
  118. last_name = input("What is your last name? ")
  119.  
  120. user = create_mls(first_name, last_name)
  121. print("Your MLS username is {:s}".format(user))
  122.  
  123. Q2 MAIN
  124. """
  125. -------------------------------------------------------
  126. q2.py
  127. createss login for the user
  128. -------------------------------------------------------
  129. Author: Ralph Suyat
  130. ID: 160516270
  131. Email: Suya6270@mylaurier.ca
  132. Section: B
  133. __updated__ = "2016-11-14"
  134. -------------------------------------------------------
  135. """
  136. from credentials import create_login
  137. for i in range(0, 6):
  138. name = input("Enter last name and student ID: ")
  139. user = create_login(name)
  140. print("Your Login into MLS is {:s}".format(user))
  141.  
  142. Q3 Main
  143. """
  144. -------------------------------------------------------
  145. q3.py
  146. creates MLS password
  147. -------------------------------------------------------
  148. Author: Ralph Suyat
  149. ID: 160516270
  150. Email: Suya6270@mylaurier.ca
  151. Section: B
  152. __updated__ = "2016-11-14"
  153. -------------------------------------------------------
  154. """
  155. for i in range(0, 6):
  156. from credentials import create_pass
  157. phrase = input("Enter a phrase: ")
  158. password = create_pass(phrase)
  159. print("Your MLS Password is: {:s}".format(password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement