Question

In: Computer Science

Instructions Complete the program below. The program should be turned in as a .py file. Please...

Instructions

Complete the program below. The program should be turned in as a .py file. Please turn in the .py file itself (do not take a picture of it or copy/paste it into another program). Please also turn in the output for your program. The output should be in a different file. You may find the easiest way is to take a screenshot of your output. You can use the snipping tool on Windows or the grab tool on a Mac to take pictures of your output. You may want to put all of your output pictures in a single Word file.

Criteria for Success

Please view the rubric to ensure you are completing everything you need. You are required to use functions. In addition, make sure the output examples you turn in show a variety of test cases. You can create a test() function in your program to prove the majority of your code works.

Password Validator

When users create a new account on a website, they are often asked to create a new password. Many websites then test the password to make sure it is strong enough before allowing a user to save it. If it's not strong enough, the user needs to create a new password.  

In this program, you will ask a user for a username/password combination and test for password strength according to the following rules:

  • Must be at least 8 characters and less than 21 characters (20 characters is OK, 21 is not)
  • Must contain both an upper and lowercase letter
  • Must contain a digit (0-9)
  • Must contain a punctuation mark (!+.@$%*)
  • Must ONLY consist of letters (A-Z), (a-z), digits (0-9) and !+.@$*.

Your program will prompt for a username. Then, it will prompt for a password. Your program should check the password. If the password is OK, print "Good Password!" and end the program. If the password is NOT OK, print the appropriate message to the user. Continue reprompting until the user successfully picks a good password.

If there are multiple problems with the password, you only need to report one.

Consider: Is this the most user-friendly approach?

No. It's not. But it does seem some websites continue to hassle the user this way, while others let the user know up front what is expected... And give better error messages than these, often reincluding what is required. I prefer those sites. However, I want you to write the code that can give specific errors.

Obvious Password

Rule: If a password contains 1 or more of the following Strings (ignore case):

  • password
  • 1234
  • 111111
  • Qwerty123
  • Abcd99
  • football
  • dragon
  • letmein
  • iloveyou
  • admin
  • login
  • welcome
  • flower
  • zaq1
  • Password1

Message to user: Don't use common passwords

Too Short Password

Rule: Password must be at least 8 characters long

Message to user: Password must be at least 8 characters long

Too Long Password

Rule: Password must be less than 21 characters long

Message to user: Password must be less than 21 characters

Low Complexity Password

Rule: The password must contain at least 1 character each of:

  • lowercase letter
  • uppercase letter
  • digit
  • punctuation mark (!+.@$%*)

Message to user: Passwords must contain both upper and lower case letters, at least one digit and at least one punctuation mark (!+.@$%*)

Unrecognized Character

Rule: Your company's back-end systems don't like certain characters. Therefore, the password must only contain:

  • Letters (A-Z) or (a-z)
  • Digits (0-9)
  • Punctuation (!+.@$%*) (no parentheses)

Message to user: Password contains an Invalid Character

Other Issues

Rule: If the password has one of the following issues, alert the user of the issue and have them choose a new one.

  • Password contains the username (ignoring case)
  • Password is the same as the username spelled backwards (ignoring case)

Message to User: Passwords can't contain a variation of the username

Pig Latin Translator

Write a program that asks the user for a sentence and converts it to Pig Latin. The below explains how to convert to Pig Latin:

If the first letter is a vowel (a, e, i, o, u):

  • Add "way" to the end of the word.

If the first letter is a consonant (treat the letter "y" as a consonant):

  • Remove the first letter and place that letter at the end of the word. Then append the string "ay" to the end of the word

Words that have their first letter capitalized, should continue to have the (possibly new) first letter capitalized.

Sentences end with a period (.), an exclamation point (!) or a question mark (?). Make sure the punctuation continues to stay at the end of the sentence.

English Pig Latin
sleep leepsay
the hetay
python ythonpay
computer omputercay
pig igpay
Latin Atinlay
if ifway
other otherway
only onlyway
apple appleway

Sentences occassionally have other punctuation such as commas (,) and semicolons (;). Make sure these punctuation marks stay put.

For example:

Original sentence: Hello World!
Right: Ellohay orldway!
NOT: elloHay orld!Way

Original sentence: To be, or not to be?
Right: Otay ebay, orway otnay otay ebay?
NOT: oTay e,bay orway otay e?bay

You only have to deal with the 5 punctuation marks mentioned (. ! ? , ;)


PUTHON PROGRAM

Solutions

Expert Solution

***Please upvote/thumbsup if you liked the answer***

PigLatinCalculator:-

Screenshot of the Python code:-

Output:-

Python code to copy:-

VOWELS = ['a','e','i','o','u'];
PUNCTUATIONS = ['.' ,'!' ,'?' , ';'];


def ConvertWordToPigLatin(word):

flag = False

for v in VOWELS:
  
if(word[0:1] == v):
if (word[len(word) - 1] not in PUNCTUATIONS):
word = word + "way"
flag = True
break
else:
word = word[0:len(word) - 2] + "way" + word[len(word) - 1]
flag = True
break

if(bool(flag) == False):
if (word[len(word) - 1] not in PUNCTUATIONS):
word = word[1:] + word[0:1] + "ay"
else:
  
word = word[1:len(word) - 1]+ word[0:1] + "ay" + word[len(word) - 1]
  
return word

sentence = input("Enter sentence");

if (sentence[0:1].isupper()):
flag = True
else:
flag = False

sentence = sentence.lower()

word_arr = sentence.split(" ")

piglatinarr = []

for word in word_arr:

piglatinarr.append(ConvertWordToPigLatin(word))

if flag == True:
piglatinarr[0] = piglatinarr[0][0].capitalize() + piglatinarr[0][1:]   

print(" ".join(piglatinarr))   


Related Solutions

Please complete the following code in C using the comments as instructions. Further instructions are below...
Please complete the following code in C using the comments as instructions. Further instructions are below the code. challenge.c // goal: print the environment variables to the file "env.txt", one per line // (If envp is NULL, the file should be empty, opening in write mode will do that.) // example: // inputs: // envp/environ = {"E1=2","E2=7",NULL} // outputs: // env.txt as a string would be "E1=2\nE2=7\n" // example: // inputs: // envp/environ = {NULL} or NULL // outputs: //...
Instructions: You must complete the questions below. All will be included in a SINGLE PDF file...
Instructions: You must complete the questions below. All will be included in a SINGLE PDF file and turned into Blackboard or handed at the start of class. The due date is specified on the syllabus. Remember, late work is not accepted. You will need an Executive Summary, PowerPoint (one to page/color) and Excel spreadsheet. Be prepared to present your findings in class. Purpose: You must evaluate the various options to ship freight from Asia to the USA. You MUST find...
Please follow the instructions carefully and complete the code given below. Language: Java Instructions from your...
Please follow the instructions carefully and complete the code given below. Language: Java Instructions from your teacher: (This is a version of an interview question I once saw.) In this problem, we will write a program that, given an integer k, an integer n, and a list of integers, outputs the number of pairs in in the list that add to k. To receive full credit for design, your algorithm must have a runtime in O(n) , where n is...
Create a geoprocessing tool from the .py file included (script from this file included below). Use...
Create a geoprocessing tool from the .py file included (script from this file included below). Use any csv file you would like. I will work around that. This is for a programming for GIS class. We work with jupyter, idle, arcgis pro import os import arcpy from arcpy import env input_table = r"C:\Answers\January2018.CSV" output_fc = r"C:\Answers\crime.gdb\January2018_Crime" spRef = arcpy.SpatialReference("NAD 1983 StatePlane Missouri East FIPS 2401 (US Feet)") gdb_name = os.path.dirname(output_fc) fc_name = os.path.basename(output_fc) env.overwriteOutput = True print("Creating File GDB") arcpy.CreateFileGDB_management(os.path.dirname(gdb_name),...
/* Complete this javascript file according to the individual instructions given in the comments. */ //...
/* Complete this javascript file according to the individual instructions given in the comments. */ // 1) Declare an array named myArray // Assign myArray three elements: 'Tuesday',3,true // Print myArray to the console with console.log() // 2) Use typeof on each element in myArray // Example: typeof myArray[0]; // Print all 3 lines to the console with console.log() // 3) Declare a variable named myStart and set it to // the value of the length property applied of myArray...
Writing Assignment #1 Instructions The following assignment should be typed and printed or handwritten and turned...
Writing Assignment #1 Instructions The following assignment should be typed and printed or handwritten and turned in to the CA office in room​ 201 TMCB.​ If there is no one in the CA Office, you can slip your assignment through the slot in the door. You must follow the instructions below or you will not receive credit.​ You can turn in the assignment up until 5:00 PM on the due date. Important Notices: If you do not staple multiple pages,...
/* Assignment : Complete this javascript file according to the individual instructions given in the comments....
/* Assignment : Complete this javascript file according to the individual instructions given in the comments. */ // 1) Utilize comments to prevent the following line from executing alert('Danger!'); // 2) Assign a value of 5 to a variable named x // and print the value of x to the console // 3) Assign a value of 10 to a variable named myNum // and print the value of myNum to the console // 4) Assign the product of x...
/* Assignment: Complete this javascript file according to instructions given in the comments. */ // 1)...
/* Assignment: Complete this javascript file according to instructions given in the comments. */ // 1) Declare a variable named myName equal to your first name //Firstname is Susan // Construct a basic IF statement that prints the variable to the // console IF the length of myName is greater than 1 // 2) Copy your IF statement from above and paste it below // Change the IF statement to check if the length of myName // is greater than...
/* Assignment : Complete this javascript file according instructions in comments. */ // 1) Create a...
/* Assignment : Complete this javascript file according instructions in comments. */ // 1) Create a for loop that loops through its code block 10 times // In the first statement, set the variable i equal to zero // In the second statement, tell the loop to execute while i is less than ten // In the third statement, increment i by one each time the loop executes // In the code block of the loop, print the variable i...
/* complete javascript file according to the individual instructions given in the comments. */ // 1)...
/* complete javascript file according to the individual instructions given in the comments. */ // 1) Prompt the user to enter their first name. // Display an alert with a personal greeting for the user // with their first name (example: Hello, Dave!) // 2) Create a Try code block that will cause a ReferenceError. // Create a Catch code block that will display the error in the // console with console.error() // 3) Prompt the user to enter a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT