Question: Write a Python program to check if a user input tirst name of a boy or girl is popular. The 200 most popular boys' names



Write a Python program to check if a user input tirst name of a boy or girl is popular. The 200 most popular boys' names and a separate list of the 200 most populax girls' names are on Pilot under lab 6 contents. Your program checks to determine if your input first name is on the boy's list or the girl's list. Your program should first ask the user if they want to enter a boy's name or a girl's name. If they select boy's names, then the program will open the boy's name popular 1 ist file. Same for the girl's 1ist. The files are structured with. a single first name per 1 ine with a total of 200 iines per file. Use a text editor to check the contents of the files. Use a try - except block to catch a file name error. If there is an exception for file not found, then use the exit function is used to stop the program. Use a while loop to select ' b ' for boy's names or ' g ' for girl 's names. The loop continues to prompt the user if they enter something other than a 'b' or " g '. Open the appropriate file .. only one file .- not both. Read the text of the tile (i.e. the list of 200 names) into a string and then use 'split' to split the string into a list. Split at the end of line character. Use the 'in' list operator to determine if the name the user selects is in the list. If the name is popular (i.e. it is found in the list), then the program should so report. In a similar manner, it should report if the name is not. popular. A while loop is used to continue with name selections until the user presses enter when prompted for a name. Thus, a name of zero length terminates the code. The tile that was opened is then closed. Sample Run (user input in bold) : Check Boy's or Girl's names? (Enter b or g ) : a Invalid input: Enter b or g. Check Boy's or Girl's names? (Enter b or g ) : z Invalid input: Enter b or g. Check Boy's or Girl's names? (Enter b or g ) :b Enter name:Benjamin Benjamin is a popular name. Enter name: Robert Robert is a popular name. Enter name: Theodore Theodore is not on the popular name list. Enter name: Name 1 ist checking is finished page 1 of 2 Lab 06 cs 1160 spring 2023 - File: - Date: 4 Checking Popular Boy's and Girl's Names 4 Use try except to catch file or input errors try: * Ask for boy's list or girl's 1ist - while loop * 'readbg' is True to start and then False when ' b ' or ' g ' entered while readbg: i keep asking until 'b' or ' g ' entered 4 Print file exception and exit program except. Exception as err: print (err) print ('Execution terminates.') exit () read the file as a string and split at end of 1 ine * ask user for name, determine popularity, and 1) exit on empty string name. start while loop on testing names close the file Cheok List and Grading Points (Rubric) : 10 points total max 1. Name your file fileprefixlab06.py and include header block as shown (1 points) 4 Name: (your name) * Course: cs 1160 * Assignment: Lab 06 - Date Assigned: 3/06/2023 - Filename: fileprefixlab06,py i Brief Description: Checking Popular Names 2. Use meaningful comments in your program. (1 points) 3. Proper use of open, read, split, close functions (4 points) 4. Results in agreement with sample test cases (4 points) Required submittals: Turn in to the Lab 6 Dropbox both a py file and txt file of your code. Emily Madison Emma Olivia Hannah Abigail Isabella Samantha Elizabeth Ashley Alexis Sarah Sophia Alyssa Grace Ava Taylor Brianna Lauren Chloe Natalio Kayla Jessica Anna Victoria Mia Hailey Sydney Jasmine Julia Morgan
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
