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

Do the following parts of this lab 

**Part 2:**

Open an XML file for writing and write data to that file as follows:

```xml
<?xml version="1.0" ?>
<students>
    <student>
        <firstName>Jane</firstName>
        <lastName>Doe</lastName>
        <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.

```python
import json
filename = input("Enter name of file: ")
infile = open(filename, "r")

# Read the file object into a python dictionary
students_d = json.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 <?xml version="1.0" ?> <students> <student> <firstName>Jane</firstName> <lastName>Doe</lastName> <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. ```python import json filename = input("Enter name of file: ") infile = open(filename, "r") # Read the file object into a python dictionary students_d = json.load(infile) print(students_d) infile.close() ```
**Lab 14: Processing a JSON File**

**Objective:**  
Read in a JSON file structured as follows:

```json
{
  "students": [
    {
      "firstName": "Jane",
      "lastName": "Doe",
      "major": "CENT",
      "credits": 12,
      "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

**Explanation:**  
The JSON file contains an array of student objects. Each student object includes the student's first and last names, major, credits, and an array of exam scores. The task involves parsing this JSON data to extract and display the students' names alongside their majors.
expand button
Transcribed Image Text:**Lab 14: Processing a JSON File** **Objective:** Read in a JSON file structured as follows: ```json { "students": [ { "firstName": "Jane", "lastName": "Doe", "major": "CENT", "credits": 12, "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 **Explanation:** The JSON file contains an array of student objects. Each student object includes the student's first and last names, major, credits, and an array of exam scores. The task involves parsing this JSON data to extract and display the students' names alongside their majors.
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