Difference between revisions of "CSC111 Final Exam 2018"
Line 22: | Line 22: | ||
* Write a python program that reads this type of CSV file, and outputs this information: | * 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. For example, if the 3 lines shown below, CSC is the most frequent major. | ::* 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. | ||
− | + | <br /> | |
− | + | :::::<source lang="text"> | |
− | + | Flo72@hampshire.edu,RUL,CSC, | |
− | + | Anna10@hampshire.edu,CSC,ECO, | |
− | + | Monty77@smith.edu,CSC,RUL,, | |
+ | </source> | ||
+ | <br /> | ||
::* The most popular minor | ::* The most popular minor | ||
::* 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. | ::* 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: | ||
− | + | <br /> | |
− | + | :::::<source lang="text"> | |
− | + | GEO | |
− | + | ITL | |
− | + | CSC-ECO | |
− | + | smith.edu | |
+ | </source> | ||
+ | <br /> | ||
* 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 "---". | * 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: | ||
− | + | <br /> | |
− | + | :::::<source lang="text"> | |
− | + | GEO | |
− | + | --- | |
− | + | --- | |
− | + | smith.edu | |
+ | </source> | ||
+ | <br /> | ||
* 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: | * 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 | ||
− | + | <br /> | |
− | + | :::::<source lang="text"> | |
− | + | GEO ITL | |
− | + | CSC ICO PHY | |
− | + | CSC-ECO ECO-MTH | |
− | + | hampshire.edu smith.edu umass.edu | |
+ | </source> | ||
+ | <br /> | ||
* Here is an example of the interaction with a user who mistypes the name of the file: | * Here is an example of the interaction with a user who mistypes the name of the file: | ||
− | + | <br /> | |
− | + | :::::<source lang="text"> | |
− | + | > hello | |
− | + | > this is an invalid file name | |
− | + | > test2.csv | |
− | + | ||
− | + | RUL | |
− | + | --- | |
− | + | CSC-RUL ECO-RUL | |
− | + | amherst.edu hampshire.edu mtholyoke.edu smith.edu umass.edu | |
+ | </source> | ||
+ | <br /> | ||
:: Note that the program <font color="red">prints a blank line after getting a valid file name and before outputting the result.</font> | :: 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. |