Lab 14: Processing a json file Read in a JSON file such as the following: { "students":[ { { }, "firstName" "lastName" : "Doe", "major": "CENT", "credits": 12, : "Jane", "exams" : [92.7, 91.4, 95.2] "firstName" : "John", "lastName": "Doe", "major": "PHYS", "credits" : 10.0, exams : [91.1, 81.3, 85.6]

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Lab 14: Processing a json file
Read in a JSON file such as the following:
{
"students":[
}
{
},
{
"firstName"
"lastName : "Doe",
"major" : "CENT",
"credits": 12,
: "Jane",
"exams" : [92.7, 91.4, 95.2]
"firstName" : "John"
"lastName' : "Doe"
"major": "PHYS",
"credits" : 10.0,
"exams : [91.1, 81.3, 85.6]
"firstName" : "Bill",
"lastName : "Gates",
"major": "ICS",
"credits" : 7,
exams" : [98.7, 94.4, 96.4]
PART 1:
Parse the JSON data into a dictionary and output the data as follows:
Jane Doe is majoring in CENT
John Doe is majoring in PHYS
Bill Gates is majoring in ICS
Transcribed Image Text:Lab 14: Processing a json file Read in a JSON file such as the following: { "students":[ } { }, { "firstName" "lastName : "Doe", "major" : "CENT", "credits": 12, : "Jane", "exams" : [92.7, 91.4, 95.2] "firstName" : "John" "lastName' : "Doe" "major": "PHYS", "credits" : 10.0, "exams : [91.1, 81.3, 85.6] "firstName" : "Bill", "lastName : "Gates", "major": "ICS", "credits" : 7, exams" : [98.7, 94.4, 96.4] PART 1: Parse the JSON data into a dictionary and output the data as follows: Jane Doe is majoring in CENT John Doe is majoring in PHYS Bill Gates is majoring in ICS
PART 2:
Open an XML file for writing and write data to that file as follows:
<?xml version="1.0" ?>
<students>
<student>
<firstName>Jane</firstName>
<lastName>Doe</lastName>
www
<major>CENT</major>
<credits>12</credits>
</student>
<student>
<firstName>John</firstName>
<lastName>Doe</lastName>
<major>PHYS</major>
<credits>10.0</credits>
</student>
<student>
<firstName>Bill</firstName>
<lastName>Gates</lastName>
<major>ICS</major>
<credits>7</credits>
</student>
</students>
Part 3:
Add a function that takes a list of floats and returns the average value.
Use the function to add the average exam score for each student in the XML file.
import json
filename
infile open (filename, "r")
input ("Enter name of file: ")
# Read the file object into a python dictionary
students_djson.load(infile)
print (students_d)
infile.close()
Transcribed Image Text:PART 2: Open an XML file for writing and write data to that file as follows: <?xml version="1.0" ?> <students> <student> <firstName>Jane</firstName> <lastName>Doe</lastName> www <major>CENT</major> <credits>12</credits> </student> <student> <firstName>John</firstName> <lastName>Doe</lastName> <major>PHYS</major> <credits>10.0</credits> </student> <student> <firstName>Bill</firstName> <lastName>Gates</lastName> <major>ICS</major> <credits>7</credits> </student> </students> Part 3: Add a function that takes a list of floats and returns the average value. Use the function to add the average exam score for each student in the XML file. import json filename infile open (filename, "r") input ("Enter name of file: ") # Read the file object into a python dictionary students_djson.load(infile) print (students_d) infile.close()
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY