Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTIONS
- """
- -------------------------------------------------------
- credentials.py
- all functions needed for a14
- -------------------------------------------------------
- Author: Ralph Suyat
- ID: 160516270
- Email: suya6270@mylaurier.ca
- Section B
- __updated__ = "2016-11-14"
- -------------------------------------------------------
- """
- def create_mls(first_name, last_name):
- """
- -------------------------------------------------------
- Creates username of user for MLS
- use: user = create_mls(first_name, last_name)
- -------------------------------------------------------
- Preconditions:
- first_name - the users inputed first name (str)
- last_name - the users inputed last name (str)
- Postconditions:
- return
- user - the username for MLS using the first and last name
- -------------------------------------------------------
- """
- user = ""
- user += first_name[0:1].lower()
- for char in last_name:
- if char.isalpha():
- user += char.lower()
- return user
- def create_login(name):
- """
- -------------------------------------------------------
- Creates login of user for MLS
- use: login = create_login(name)
- -------------------------------------------------------
- Preconditions:
- name - the users inputed last name (str)
- Postconditions:
- return
- user - the login for MLS using the last name and student id
- -------------------------------------------------------
- """
- user = ""
- beginning = name[:4]
- last = name[-4:]
- for char in beginning:
- if (char.isalpha()):
- user += char
- else:
- user += "x"
- for char in last:
- user += char
- return user.lower()
- def create_pass(phrase):
- """
- -------------------------------------------------------
- Creates password for user for MLS
- use: login = create_pass(phrase)
- -------------------------------------------------------
- Preconditions:
- phrase - users choice of sentence (str)
- Postconditions:
- return
- password - the password for MLS
- -------------------------------------------------------
- """
- password = ""
- words = phrase.split(" ")
- for j in range(0, len(words)):
- password += get_alnum(words[j])
- return password
- def get_alnum(word):
- """
- -------------------------------------------------------
- Retrieves first valid char in the string and is used in the pass creation
- use: get_alnum(word)
- -------------------------------------------------------
- Preconditions:
- word - the users inputed phrase (str)
- Postconditions:
- return
- word - first valid char in the string
- -------------------------------------------------------
- """
- for i in range(0, len(word)):
- if word[i].isalnum():
- return word[i]
- Q1 MAIN
- """
- -------------------------------------------------------
- q1.py
- creates the users username
- -------------------------------------------------------
- Author: Ralph Suyat
- ID: 160516270
- Email: Suya6270@mylaurier.ca
- Section: B
- __updated__ = "2016-11-14"
- -------------------------------------------------------
- """
- for i in range(0, 6):
- from credentials import create_mls
- first_name = input("What is your first name? ")
- last_name = input("What is your last name? ")
- user = create_mls(first_name, last_name)
- print("Your MLS username is {:s}".format(user))
- Q2 MAIN
- """
- -------------------------------------------------------
- q2.py
- createss login for the user
- -------------------------------------------------------
- Author: Ralph Suyat
- ID: 160516270
- Email: Suya6270@mylaurier.ca
- Section: B
- __updated__ = "2016-11-14"
- -------------------------------------------------------
- """
- from credentials import create_login
- for i in range(0, 6):
- name = input("Enter last name and student ID: ")
- user = create_login(name)
- print("Your Login into MLS is {:s}".format(user))
- Q3 Main
- """
- -------------------------------------------------------
- q3.py
- creates MLS password
- -------------------------------------------------------
- Author: Ralph Suyat
- ID: 160516270
- Email: Suya6270@mylaurier.ca
- Section: B
- __updated__ = "2016-11-14"
- -------------------------------------------------------
- """
- for i in range(0, 6):
- from credentials import create_pass
- phrase = input("Enter a phrase: ")
- password = create_pass(phrase)
- print("Your MLS Password is: {:s}".format(password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement