Try Full Version Ti Cot HW2 Python TO A A : ENG 101 – Python Homework #2 Due Tuesday, November 26 at 11:59 pm (Canvas submission) You are to submit only ONE file named “HW2.py” with four functions in the file for each of the problems. Each function should have a docstring with help on the function and the assignment header information. 1. Pretend you work for an online email site. Your job is to develop a function called “password” with one input and one output that asks for user names and passwords. If the input value is “True” it set up new users. If the input value is “False” it checks for a current user name and password. The output is “True” if the function successfully created a new user or if the user entered the valid user name with the correct password for a current user, otherwise, the output is “False”. The function should prompt the users for a user name and password. If it is a new user, it should append the new user name and password to a file called “userpass.csv” with a comma used as the delimiter. If it is a current user, it only needs to check if the user name is in the file and if the password is correct for that user. a. A valid user name should be at least 6 characters long and less than 17 characters and check that it has not been used before in userpass.csv. b. The password is valid only if the following conditions are met: • At least 1 lower case letter [a-z] • At least 1 upper case letter between [A-Z). • At least 1 number between [0-9]. • At least 1 of the following special characters: -, !,@,#, S% , &,,, or> • Any other characters cannot be used in a password. • Minimum length of 6 characters. • Maximum length of 16 characters The input commands should not be in a loop but only asked for the user name and password once. If the conditions for a valid password are not met the function should tell the user what is wrong with the password. The function should give an error if it is a new user and the user name has already been selected. For a current user, it should give an error only if both the user name and password do not match what is in the “userpass.csv” file. Hint: Use the ord function to check the ASCII value of individual characters. 2. Use the grocery.py file on Canvas to start your program for this problem. It contains two dictionaries of stock and price. Create a function called “grocery cost” that has one input (dictionary with food items and quantities). The function will have two outputs of the total cost of a shopping list and the dictionary with food items and quantities sold. The function should check each item in the input dictionary and determine if the item is do funtion hould display Show transcribed image text Try Full Version Ti Cot HW2 Python TO A A : ENG 101 – Python Homework #2 Due Tuesday, November 26 at 11:59 pm (Canvas submission) You are to submit only ONE file named “HW2.py” with four functions in the file for each of the problems. Each function should have a docstring with help on the function and the assignment header information. 1. Pretend you work for an online email site. Your job is to develop a function called “password” with one input and one output that asks for user names and passwords. If the input value is “True” it set up new users. If the input value is “False” it checks for a current user name and password. The output is “True” if the function successfully created a new user or if the user entered the valid user name with the correct password for a current user, otherwise, the output is “False”. The function should prompt the users for a user name and password. If it is a new user, it should append the new user name and password to a file called “userpass.csv” with a comma used as the delimiter. If it is a current user, it only needs to check if the user name is in the file and if the password is correct for that user. a. A valid user name should be at least 6 characters long and less than 17 characters and check that it has not been used before in userpass.csv. b. The password is valid only if the following conditions are met: • At least 1 lower case letter [a-z] • At least 1 upper case letter between [A-Z). • At least 1 number between [0-9]. • At least 1 of the following special characters: -, !,@,#, S% , &,,, or> • Any other characters cannot be used in a password. • Minimum length of 6 characters. • Maximum length of 16 characters The input commands should not be in a loop but only asked for the user name and password once. If the conditions for a valid password are not met the function should tell the user what is wrong with the password. The function should give an error if it is a new user and the user name has already been selected. For a current user, it should give an error only if both the user name and password do not match what is in the “userpass.csv” file. Hint: Use the ord function to check the ASCII value of individual characters. 2. Use the grocery.py file on Canvas to start your program for this problem. It contains two dictionaries of stock and price. Create a function called “grocery cost” that has one input (dictionary with food items and quantities). The function will have two outputs of the total cost of a shopping list and the dictionary with food items and quantities sold. The function should check each item in the input dictionary and determine if the item is do funtion hould display
Expert Answer
Answer to Try Full Version Ti Cot HW2 Python TO A A : ENG 101 – Python Homework #2 Due Tuesday, November 26 at 11:59 pm (Canvas su…