Assignment 7 part 1
Part 1: Username & Password
Validator
This program has been
oken into two parts. You can submit them
oth as one single file as the programs build upon each other.
Part 1a: Username Validator
You have been asked to write a username validation program for a
small website. The website has specific rules on what constitutes a
valid username, including:
• All usernames must be between 8 and 15 characters long
• Usernames can only contain alphabetic (a-z and A-Z) and
numeric characters XXXXXXXXXXno special characters or spaces are
allowed.
• The first and last characters in a username cannot be a digit
• Usernames must contain at least one uppercase characte
• Usernames must contain at least one lowercase characte
• Usernames must contain at least one numeric characte
Write a program that asks the user to enter in a username and then
examines that username to make sure it complies with the rules
above. Here's a sample running of the program - note that you
want to keep prompting the user until they supply you with a valid
username. User input is underlined:
Enter a username: craig
* Length of username: 5
* All characters are alpha-numeric: True
* First & last characters are not digits: True
* # of uppercase characters in the username: 0
* # of lowercase characters in the username: 5
* # of digits in the username: 0
Username is invalid, please try again
Enter a username: craig123
* Length of username: 8
* All characters are alpha-numeric: True
* First & last characters are not digits: False
* # of uppercase characters in the username: 0
* # of lowercase characters in the username: 5
* # of digits in the username: 3
Username is invalid, please try again
Enter a username: craig 123
* Length of username: 9
* All characters are alpha-numeric: False
* First & last characters are not digits: False
* # of uppercase characters in the username: 0
* # of lowercase characters in the username: 5
* # of digits in the username: 3
Username is invalid, please try again
Enter a username: Craig123
* Length of username: 8
* All characters are alpha-numeric: True
* First & last characters are not digits: False
* # of uppercase characters in the username: 1
* # of lowercase characters in the username: 4
* # of digits in the username: 3
Username is invalid, please try again
Enter a username: Craig123!
* Length of username: 9
* All characters are alpha-numeric: False
* First & last characters are not digits: True
* # of uppercase characters in the username: 1
* # of lowercase characters in the username: 4
* # of digits in the username: 3
Username is invalid, please try again
Enter a username: Craig123T
* Length of username: 9
* All characters are alpha-numeric: True
* First & last characters are not digits: True
* # of uppercase characters in the username: 2
* # of lowercase characters in the username: 4
* # of digits in the username: 3
Username is valid!
Hint: you will need to count the # of uppercase, lowercase and digit
characters using some kind of loop.
Part 1a is an intermediate step towards the final version of this
program. You do not need to turn in this part of the program - keep
working and turn in part 1b when you are finished. You only need
to turn in part 1b.
Part 1b: Password Validator
This is a solo project. You may start working in your Ed workspace
as a group to help each other out, but after class everyone should
download any work written by the group and continue working
locally on their own computer. You will be doing yourself a HUGE
disservice by not working on this project by yourself! If you do
share tips with one another please be sure to include everyone's
name at the top of your program. Note that "sharing tips" does not
mean "copied the entire program" from someone else.
• Passwords must be at least 8 characters long (but they do not
have an upper limit)
• Passwords cannot contain the user's username (i.e. if the
username is "My1stUsername" the password cannot be
"abcMy1stUsername" or "My1stUsernameABC" because the
username String can be found in the password String)
• Passwords must be a mixture of uppercase letters (A-Z),
lowercase letters (a-z), digits (0-9) and a select number of
special characters (#, $, % and &). The password must
contain at least one of each of these types of characters in
order to be valid.
• Passwords cannot contain any duplicate characters (i.e. the
user cannot use the character 'a' more than 1 time in the
password)
You can make a copy of Part 1a and place your password validator
code directly after your username validator. Here's a sample
unning of the program. Note that you need to continually ask the
user for a password until they supply a good one.
Enter a username: Craig123T
* Length of username: 9
* All characters are alpha-numeric: True
* First & last characters are not digits: True
* # of uppercase characters in the username: 2
* # of lowercase characters in the username: 4
* # of digits in the username: 3
Username is valid!
Enter a password: x
* Length of password: 1
* Username is part of password: False
* # of uppercase characters in the password: 0
* # of lowercase characters in the password: 1
* # of digit characters in the password: 0
* # of special characters in the password: 0
* # of invalid characters in the password: 0
Password is invalid, please try again
Enter a password: Craig123T
* Length of password: 9
* Username is part of password: True
* # of uppercase characters in the password: 2
* # of lowercase characters in the password: 4
* # of digit characters in the password: 3
* # of special characters in the password: 0
* # of invalid characters in the password: 0
Password is invalid, please try again
Enter a password: foobar
* Length of password: 6
* Username is part of password: False
* # of uppercase characters in the password: 0
* # of lowercase characters in the password: 6
* # of digit characters in the password: 0
* # of special characters in the password: 0
* # of invalid characters in the password: 0
* duplicate character: 'o' occurs 2 times
Password is invalid, please try again
Enter a password: foohellozzz
* Length of password: 11
* Username is part of password: False
* # of uppercase characters in the password: 0
* # of lowercase characters in the password: 11
* # of digit characters in the password: 0
* # of special characters in the password: 0
* # of invalid characters in the password: 0
* duplicate character: 'o' occurs 3 times
* duplicate character: 'l' occurs 2 times
* duplicate character: 'z' occurs 3 times
Password is invalid, please try again
Enter a password: FooHelloZzz
* Length of password: 11
* Username is part of password: False
* # of uppercase characters in the password: 3
* # of lowercase characters in the password: 8
* # of digit characters in the password: 0
* # of special characters in the password: 0
* # of invalid characters in the password: 0
* duplicate character: 'o' occurs 3 times
* duplicate character: 'l' occurs 2 times
* duplicate character: 'z' occurs 2 times
Password is invalid, please try again
Enter a password: xyzCraig123Txyz
* Length of password: 15
* Username is part of password: True
* # of uppercase characters in the password: 2
* # of lowercase characters in the password: 10
* # of digit characters in the password: 3
* # of special characters in the password: 0
* # of invalid characters in the password: 0
* duplicate character: 'x' occurs 2 times
* duplicate character: 'y' occurs 2 times
* duplicate character: 'z' occurs 2 times
Password is invalid, please try again
Enter a password: xyzCraig123
* Length of password: 11
* Username is part of password: False
* # of uppercase characters in the password: 1
* # of lowercase characters in the password: 7
* # of digit characters in the password: 3
* # of special characters in the password: 0
* # of invalid characters in the password: 0
Password is invalid, please try again
Enter a password: #xyz123CraigQ
* Length of password: 13
* Username is part of password: False
* # of uppercase characters in the password: 2
* # of lowercase characters in the password: 7
* # of digit characters in the password: 3
* # of special characters in the password: 1
* # of invalid characters in the password: 0
Password is valid!
Hint: The count method may be useful for finding the # of times a
character repeats within a password.
This program should be named as follows:
"GautamDhwani_assign7_part1.py"
Assignment 7 part 2
Part 2: Simple Encryption
This program asks you to build a series of functions which will be
put together to create a simple encoder / decoder program for
secret messages. The program has been
oken into two parts.
You can submit them both as one single file as the programs build
upon each other.
Part 2a
Begin by writing the following functions using the IPO notation
elow. Test your code using the sample program below each
function header.
Function #1
# function: ascii_shift
# input: a word to shift (String) and an amount to
shift by (integer)
# processing: shifts each uppercase character in the
supplied word to another position in the ASCII
# XXXXXXXXXXtable. the new position is dictated by the
supplied integer. for example,
# XXXXXXXXXXif word = "APPLE" and num=1 the newly
generated word would be:
#
# XXXXXXXXXXBQQMF
#
# XXXXXXXXXXbecause we added +1 to each character. if
we were to call the