Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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
expand button
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()
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY