Question: You will write a function to access the file of majors and colleges represented in CIS 210, and create a list of the majors of
You will write a function to access the file of majors and colleges represented in CIS 210, and create a list of the majors of students in CIS 210, then another function to analyze the data in the list of majors. Finally, you will write a function to report the number of different majors, and the mode and frequency occurrences of the majors in the file.
Write three new functions: majors_readf, majors_analysis, and majors_report.
Function majors_readf will have one parameter, fname, a string, which is the name of the majors file. majors_readf should open file fname and create and return a list of the majors in this file.
Function majors_analysis will have one parameter, majorsli, a list of majors (the list returned by majors_readf). majors_analysis will determine the most frequently occurring major(s) (mode) in the argument list, and also the count of the number of distinct majors in the list. majors_analysis will return these results.
Function majors_report will have three parameters, majors_mode (the first item returned by majors_analysis), majors_ct (the second item returned by majors_analysis, and majorsli (the list returned by read_majorsf), and return None. It will report the mode of majorsli and the total number of majors represented in the majors list. majors_report will also call frequencyTable (from p62_data_analysis.py) to report the number of occurrences of each item in majorsli. When you have written and tested these, write function main to call functions majors_readf, majors_analysis, and majors_report. main returns None. main should look similar to this:
def main():
'''()->
None Calls: majors_readf, majors_analysis, majors_report Top level function for analysis of CIS 210 majors data. Returns None.
> majors_main() '''
#fname = 'majors_short.txt'
fname = 'p71_majors_cis210f18.txt'
majorsli = majors_readf(fname) #read
majors_mode, majors_ct = majors_analysis(majorsli) #analyze
majors_report(majors_mode, majors_ct, majorsli) #report
return None
Include code in your .py file to call the main function
given:
CIS 210 FALL 2018 Major CIS BADM MATH CIS SDSC CIS EC CIS PBA CIS CIS BADM CIS CIS EC CIS PHYS CIS GS CIS CIS MATH JPN MATH GS BADM CIS CIS CIS CIS CEP PHYS CIS CIS PHYS CIS CEP CIS GS MATH HPHY CIS CIS CIS CIS CIS EXPL CIS MDST CIS CIS CIS EXPL PBA EXPL CIS CIS CIS CIS CIS CIS GB CIS GS GS CIS PJ CIS CIS EXPL CIS CIS CIS ARCH CIS PDS PHYS EC EXPL PBA CIS MATH EC CIS CIS CIS CIS CIS CIS CIS CIS CIS BADM CIS CIS CIS CIS CIS PEN MACS CIS ATCH MATH EXPL EXPL CIS CIS CIS CIS CIS CIS CIS MACS PHYS EC PS CIS CIS LING PHIL PHYS EXPL CIS PDSG CIS CIS CIS CIS EXPL PHYS CIS EXPL BI PBA CIS CIS CIS LING CIS CIS CIS EXPL CIS CINE PBA PSY CIS CIS EXPL MATH GS CIS CIS CIS CIS CIS CIS CIS CIS CIS EXPL MACS EC
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
