Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
program
#1
definitely need help solving this program. It is due tonight at 11:59 and i am completely lost. Any and all help for answers please. Must be in python language.



The U.S. Social Security Administration publishes lists of baby names for every year since 1880.
The data for each year is stored in a separate file. The files all have the format

Name,Sex(M/F),Number

The Number is the number of children given the name in that year. These files are edited so that they are shorter and only include names with >= 100 entries for that year.

You are to create a program to provide information from these files:

-For each year of data needed, your program must read the file 'ssaxxx.txt' where xxxx is the year needed.

-The data file format is consistent and for this assignment you DO NOT have to check for errors in the data files

-You do no need to check each user input (choice and years) for errors and handle those without crashing

-The program must include a function called name(). This function takes two arguments. The first is the year as an integer and the second is the type of name to search for: 'M' for male, 'F' for female, and 'E' for everyone. The function must return both the most popular name for that year and the number of times the name was given.

To develop/test the program, you need to get the data files from 1980 to 2018, These can be found in the files section below in a zip file. You DO NOT need to upload the data files to Zybooks (only upload your program), they are only for you development purposes.

The program must offer the following options

-The first option will scan the files and print the most popular name for each year (regardless if it is male or female) along with the number of that name given for each year

-The second option will look at all all the years and find the most popular name overall and the overall total for that name

-The third option is like the first one, except it will print the most popular male name for each year along with the number of the name given for each year

-The fourth option will print the most popular female name for each year along with the total number of that name given for that year

After each option (other than quit), ask for a starting and ending year.

Sample Output Session
BABY NAME DATA

p - Most popular name
o - Most popular name overall
m - Most popular male name
f - Most popular female name
q - Quit

Enter Menu Choice: p
Starting Year: 1983
Ending Year: 1985
1983 Michael 67995
1984 Michael 67736
1985 Michael 64906

BABY NAME DATA

p - Most popular name
o - Most popular name overall
m - Most popular male name
f - Most popular female name
q - Quit

Enter Menu Choice: o
Starting Year: 1983
Ending Year: 1985
Michael 200637

BABY NAME DATA

p - Most popular name
l - Least popular name
m - Most popular male name
f - Most popular female name
q - Quit

Enter Menu Choice: r
Invalid choice...Try again!

BABY NAME DATA

p - Most popular name by year
o - Most popular name overall
m - Most popular male name
f - Most popular female name
q - Quit

Enter Menu Choice: p
Starting Year: 1976
Years must be from 1980 to 2017 !

Starting Year: 1988
Ending Year: 2100
Years must be from 1988 to 2017 ! <------- Notice the error message says 1988 in this case!!

Ending Year: 1989
1988 Michael 64133
1989 Michael 65382

BABY NAME DATA

p - Most popular name by year
o - Most popular name overall
m - Most popular male name
f - Most popular female name
q - Quit

Enter Menu Choice: q
FINAL NOTES:

It is easiest to get the solution by building the program incrementally.

Although this program can be done fairly compactly, you don't lose points by having extra lines. Implement it the best way you see fit.

HINT #1: You don't necessarily have to use the csv library. Remember you can split a string with comma seperated values. If you have a string called entry, you can say entry.split(',') and that will return a list of each entry (with no commas)

HINT #2: If you use a dictionary in any part of your program (and there are ways to do this without using dictionaries), there is a way you can get the key for the dictionary value that is the highest. If your dictionary is called entry, the call max(entry,key=entry.get) will return the KEY associated with the max value.
Reply
#2
What have you tried so far.
Show the code you have in code tags for the specific part your having problems with.
State what should happen and what's actually happening and any errors in error tags.
Reply
#3
11:59 of what time zone?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020