Python Question
MIS 532 – Spring 2024 Assignment 2 Due: 11:59PM February 28, 2024 Instructions: – Please include comments (single line and multiline comments as necessary). The first line of a script includes the assignment and the question number. The next line includes a docstring that describes the purpose of the script (see slide 13 of Control Statements PowerPoint as an example) – Test your programs thoroughly to ensure they execute and produce the correct outputs – Develop the scripts in Jupyter notebook and save solutions to all questions in one .ipynb file. Submit this .ipynb file on Canvas. Q1: Simple Text Encryption (8 points) Using what we have learned so far and the hint below, implement a function to encrypt text using a simple shift, where each letter in the plaintext is ‘shifted’ a certain number of places down or up the alphabet. For example, with a shift of 1, ‘A’ would be replaced by ‘B’, ‘B’ would become ‘C’, and so on. The function should return a new string where each alphabetic character in text has been shifted the specified number of positions in the alphabet. The function can handle both uppercase and lowercase letters. Non-alphabetic characters should remain unchanged in the encrypted text. Write a main function where the user will be prompted to enter the text they want to encrypt and the shift value. Hint: The chr() function is a built-in function that accepts an integer as its argument and returns a string representing a character at that Unicode point. For example, chr(65) would return ‘A’, the character for the Unicode point 65. The ord() function, which is the inverse function of chr() function, returns the integer that represents the Unicode character argument. For example, ord(‘A’) would return 65. Sample output: Q2: Username Checker (10 points) Write a function check_username that validates a username according to the following rules: – The username must not contain any of the following characters: @, &, ‘, (, ), , or spaces. The username must not include common domain extensions: .com, .net, .org, .edu The username must not start with an underscore _, hyphen -, or period . The username must not contain the specific word ‘iRobot’ The username must not start with the letter ‘e’ followed by digits only The username must not contain a string of exactly 7 or 10 digits, which could be mistaken for a phone number. The username must not have consecutive underscores __. MIS 532 – Spring 2024 Assignment 2 Due: 11:59PM February 28, 2024 The function should return an integer representing an error code (1 to 7) for each specific rule violated. If the username meets all requirements, the function returns -1, indicating a valid username. Write a main function that prompts the user to enter a username and uses these rules to determine if it is valid. The program should continue asking for a username until a valid one is entered. Display an appropriate message for an invalid username, including the reason based on the error code. When a valid username is entered, display a confirmation message. Q3: Email Signature with Website URL (12 points) Using what we have learned about strings, write a function format_name that formats the name in the format of LastName, FirstName MiddleInitial or LastName, FirstName (depending on whether a middle initial is provided by the user) Write another function validate_website to ensure that the website starts with http:// or https:// and ends with one of the five most common domains including – .com – .org – .net – .co – .us Lastly, write a function get_inputs to ask the user to enter their full name, job title, affiliation, and website URL. The function should validate the full name format and the website URL format, keep asking until the inputs are in the correct formats, and then call functions format_name and validate_website. The final output should display the email signature with the website URL included. Change the case of the name, job title, and affiliation based on the sample output below. MIS 532 – Spring 2024 Assignment 2 Due: 11:59PM February 28, 2024 Q4: Baby name generator (15 points) The following table shows the 20 most frequent given names for male and female births in 2022 in Illinois. The number to the right of each name is the number of occurrences in the data. (https://www.ssa.gov/cgi-bin/namesbystate.cgi) 20 Create a global list for the 20 male names and a global list for the 20 female names. Based on what we have learned so far, write a function to perform each task listed below: a. display_names_asce: display all the popular male names and female names in alphabetic order using formatted strings (see sample output below) Sample output: MIS 532 – Spring 2024 Assignment 2 Due: 11:59PM February 28, 2024 b. display_names_desc: display all the popular male names and female names in reverse alphabetic order using formatted strings (see sample output below) Sample output: MIS 532 – Spring 2024 Assignment 2 Due: 11:59PM February 28, 2024 c. generate_random_name: ask the user to enter the last name and choose M (male) or F (female). Based on these inputs, the function will generate and display a random name (using a random first name from the 20 most popular names for the gender and the last name provided by the user). Sample output: d. generate_matching_name: ask the user to enter the last name and choose M (male) or F (female). Based on these inputs, the function will generate and display all names where the first name shares the same first letter as the last name. If no first name from the most popular list meets this criterion, display “no first name starts with the first letter of your last name”. Sample output: The main function calls each of the functions sequentially: def main(): display_names_asce() display_names_desc() generate_random_name() generate_matching_name() main()
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
