Question: Question1 : Write a function named create_squares_dictionary(n) which takes an integer as a parameter and creates a dictionary where the keys are the numbers between

Question1 :

Write a function named create_squares_dictionary(n) which takes an integer as a parameter and creates a dictionary where the keys are the numbers between 1 and n inclusive and the values are the squares of the keys.

For example:

Test Result
a_dict = create_squares_dictionary(3) for key in sorted(a_dict): print(key, a_dict[key])
1 1 2 4 3 9 

Question2:

Define a function named read_student_data(filename) which takes a filename as a parameter. The function reads and returns a dictionary of student data. The name of the text file to be processed is specified in the filename parameter. The text file contains 1 or more lines of student data. Each line consists of a student name followed by their marks. Each data item in a line is separated by a comma (",") The function reads each line of student data in the file and returns a dictionary. Each key in the dictionary is a student name and the value is a list of marks for the student. Remember to close the input file.

Click here to download a sample input text file.

For example:

Test Result
a_dict = read_student_data("data_file_1.txt") for key in sorted(a_dict.keys()): print(key, a_dict[key])
Adriana Ferraro [53, 37, 43, 21, 61, 14, 56, 48, 30, 96] Damir Azhar [26, 14, 35, 97, 48, 37, 94, 58, 77, 71] Jane Chang [42, 4, 7, 90, 72, 4, 31, 47, 69, 72] Kathy Azhar [93, 87, 83, 60, 29, 48, 45, 96, 66, 71] Peter Jones [77, 72, 83, 41, 86, 52, 73, 12, 26, 97] 
a_dict = read_student_data("data_file_0.txt") for key in sorted(a_dict.keys()): print(key, a_dict[key])
Damir Azhar [26, 14, 35, 97, 48, 37, 94, 58, 77, 71]

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!