Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 3.0 help (not java) Purpose:To practice the concept of a dictionary as a record. Degree of Difficulty:Easy. Each line in the response file has

python 3.0 help (not java)

image text in transcribed

Purpose:To practice the concept of a dictionary as a record. Degree of Difficulty:Easy. Each line in the response file has the student ID, student name, and then a letter response for each question. We'll be writing a function to read the file later, but for this part, assume that the information about a student's responses has been stored in a list. The items in the list are all strings, starting with the ID, the student name, and then all the single letter responses. For example, here's a list for student named xyzzy, whose student ID is 345, and who answered 4 multiple choice questions: Write a function named index_student that takes a list like this, and returns a record, that is, a dictionary with the following fields:'ID', 'Name', and 'Responses'. The values for 'ID' and 'Name' are simply the first two items in the list. You should use your function index_responses() (from Question 1) to create a dictionary out of the rest of the list, and use it as the value for the 'Responses' key. Before going on, you want to be sure that your function works properly. Add the following testing code to to your program (you can find this code in a3q2-testing.py print('Testing index_student()') print(index.student(['345','xyzzy','a','a','c','b'])) print(index_student(['10021795','Samden Cross','d','d','b','e','e','e','d','a'])) You should see console output like this: Testing index_student() {'Responses':{'Q1':'a', 'Q4':'b', 'Q3':'c', 'Q2':'a'}, 'ID':'345', 'Name':'xyzzy'} {'Responses':{'Q8':'a', 'Q6':'e', 'Q7':'d', 'Q3':'b', 'Q5':'e', 'Q1':'d', 'Q4':'e', 'Q2':'d'}, 'ID':'10021795', 'Name':'Samden Cross'} Python decides what order to put the items in a record, so if you get a different ordering, that's fine. You should check that all the information is correct and associated with the appropriate keys. When you are confident that your index_student() function works, comment out the above testing code and move on to the next

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

If lim x1 f(x) = 4, find lim x-1 f(x 2 ).

Answered: 1 week ago

Question

Define marketing concepts.

Answered: 1 week ago

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago