Difference between revisions of "CSC111 Final Exam 2018"
Line 4: | Line 4: | ||
=Problem 1= | =Problem 1= | ||
− | * | + | * Write a program that prompts the user for the name of a CSV file that contains the email addresses of 5-college students along with their major or double-major, and, possibly, their minor. |
− | * Here | + | * Here is a typical file: |
email, major1, major2, minor | email, major1, major2, minor | ||
Line 12: | Line 12: | ||
Sol937@hampshire.edu,CSC,, | Sol937@hampshire.edu,CSC,, | ||
Loreen219@smith.edu,ITL,ENV, | Loreen219@smith.edu,ITL,ENV, | ||
− | |||
Marquerite747@amherst.edu,DAN,,BUX | Marquerite747@amherst.edu,DAN,,BUX | ||
− | |||
Alishia128@hampshire.edu,AMS,, | Alishia128@hampshire.edu,AMS,, | ||
Nolan149@smith.edu,SAX,, | Nolan149@smith.edu,SAX,, | ||
Line 21: | Line 19: | ||
Dominique1@smith.edu,ESS,,LALS | Dominique1@smith.edu,ESS,,LALS | ||
− | * Write a python program that reads this type of file | + | * Write a python program that reads this type of CSV file, and outputs this information: |
− | ::* The most popular major. In this case both the first major and second major count. | + | ::* The most popular major. In this case both the first major and second major count. For example, if the 3 lines shown below, CSC is the most frequent major. |
+ | |||
+ | Flo72@hampshire.edu,RUL,CSC, | ||
+ | Anna10@hampshire.edu,CSC,ECO, | ||
+ | Monty77@smith.edu,CSC,RUL,, | ||
+ | |||
::* The most popular minor | ::* The most popular minor | ||
− | ::* The most popular double major or double majors. In | + | ::* The most popular double major or double majors. In the 3 lines above, CSC-RUL is the most common double-major, and should be listed as CSC-RUL, and not RUL-CSC, since CSC is before RUL, alphabetically. |
::* Which email domain is most frequent in the file. | ::* Which email domain is most frequent in the file. | ||
* Example of output: | * Example of output: | ||
Line 33: | Line 36: | ||
smith.edu | smith.edu | ||
− | * | + | * Your program should be able to handle a file where nobody has a second major or minor. In this case the output for the double-major and minor should be "---". |
: Example: | : Example: | ||
Line 41: | Line 44: | ||
smith.edu | smith.edu | ||
− | * In case two or more majors (or minors, or double-majors) have the same largest count | + | * In case two or more majors (or minors, or double-majors, or emails) have the same largest count, then your program should output all of them on the same line, separated by spaces, and listed alphabetically: |
: Example | : Example | ||
Line 47: | Line 50: | ||
CSC ICO PHY | CSC ICO PHY | ||
CSC-ECO ECO-MTH | CSC-ECO ECO-MTH | ||
− | smith.edu | + | hampshire.edu smith.edu umass.edu |
− | + | ||
− | + | * Here is an example of the interaction with a user who mistypes the name of the file: | |
− | + | ||
− | + | > hello | |
+ | > this is an invalid file name | ||
+ | > test2.csv | ||
+ | |||
+ | RUL | ||
+ | --- | ||
+ | CSC-RUL ECO-RUL | ||
+ | amherst.edu hampshire.edu mtholyoke.edu smith.edu umass.edu | ||
+ | |||
+ | :: Note that the program <font color="red">prints a blank line after getting a valid file name and before outputting the result.</font> | ||
* Submit your program in the '''Final Exam PB 1''' section on Moodle. | * Submit your program in the '''Final Exam PB 1''' section on Moodle. | ||
<br /> | <br /> |