Question: PYTHON CODE: HELP WITH FOLLOWING CODE issues : import pickle def main(): with open(DegreesDict.dat) as fp: degrees = {} for each_line in fp: if 'Field

PYTHON CODE: HELP WITH FOLLOWING CODE issues :

import pickle

def main(): with open("DegreesDict.dat") as fp: degrees = {} for each_line in fp: if 'Field of Study' in each_line: continue # fetching data from file into variables field, deg_in_1981, deg_in_2010 = each_line.strip().split(',') change = ((float(deg_in_2010) - float(deg_in_1981)) / float(deg_in_1981)) * 100 # constructing a nested dictionary from the values in file degrees[field] = {} degrees[field]['1981'] = int(deg_in_1981) degrees[field]['2010'] = int(deg_in_2010) degrees[field]['change'] = change fp.close()

while True: # displaying the menu print(" Bachelor Degrees Menu") print("---------------------") print("1. Bachelor Degrees conferred in certain fields") print("2. Percentage change in bachelor degrees conferred") print("3. Bachelor Deegrees conferred in 2010 in certain fields") print("4. Exit from Menu") # taking option from the user option = int(input('Enter your option(1/2/3/4)? ')) if option == 1: # sorting by course name study = sorted(degrees.items()) print(" Bachelor Degree conferred in certain fields") print("--------------------------------------------------------------------") print("{0:

if __name__=='__main__': main()

PYTHON CODE: HELP WITH FOLLOWING CODE issues : import pickle def main():

Bachelor Degrees Table 5.8 shows the number of bachelor degrees conferred in 1981 and 2010 in certain fields of study. Tables 5.9 and 5.10 show the percentage change and a histogram of 2010 levels, respectively. Write a program that allows the user to display any one of these tables as an option and to quit as a fourth option. Table 5.8 is ordered alphabetically by field of study, Table 5.9 is ordered by decreasing percentages, and Table 5 is ordered by increasing number of degrees. Use the file DegreesDict.dat that stores a dictionary where each field of study is a key and each value is a two-tuple of the form (number of degrees in 1981, number of degrees in 2010). One item of the dictionary is "Business" (200521,358293). TABLE 5.8 Bachelor degrees conferred in certain fields Field of Study 1981 2010 Business 200,521 358,293 Computer and info. science 15,121 39,589 Education 108,074 101,265 Engineering 63,642 72,654 Social sciences and history 100,513 172,780 Soence: National Center for Education Statistics. TABLE 5.9 Percentage change in bachelor degrees conferred. Field of Study Change (1981-2010) Computer and info. science 161.8% Business 78.7% Social sciences and history 71.9% Engineering 14.2% Education 6.3% TABLE 5.10 Bachelor degrees conferred in 2010 in certain fields. Computer and info. science 39,589 Engineering 72,654 Education 101,265 Social sciences and history 172,780 Business ******************************h 358,293

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!