Question: Problem Description: Write a python program to check if a user input first name of a boy or girl is popular. The 200 most popular

 Problem Description: Write a python program to check if a user
input first name of a boy or girl is popular. The 200

Problem Description: Write a python program to check if a user input first name of a boy or girl is popular. The 200 most popular boys, names and a separate 11 st of the 200 most popular 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 list file. Same for the girl's list. The files are structured with a single first name per line with a total of 200 lines 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 100p 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 file (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 1ist. If the name is popular (i.e. it is found in the 1ist), 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 file 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 1 ist. Enter name: Name list checking is finished Page 1 of 2 Lab 06 CS 1160 Spring 2023 Outline of Code: * File: 4 Date: * Checking Popular Boy's and Girl's Names 1. Use try except to catch file or input errors try: Ask for boy's 1 ist or girl's list - while loop * 'readbg' is True to start and then False when ' b ' or ' g ' entered while readbg: \# keep asking until ' b ' or ' g ' entered 4 Print file exception and exit program except. Exception as err: print (err) print ('Execution terminates. ") exit() 1 read the file as a string and split at end of line * ask user for name, determine popularity, and * exit on empty string name. * start while loop on testing names * close the file Check List and Grading Points (Rubric) : 10 points total max 1. Name your file fileprefixlab06.py and include peader block as shown (1 points) * Name: (your name) * Course: CS 1160 \# Assignment: Lab 06 4 Date Assigned: 3/06/2023 * Filename: fileprefixlabo6.py \# 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!