Introduction
You have been provided with a JSON file containing information about a person, including their first name, last name, age, address, phone number, and email address.
Person Info
In this challenge, you will write a Python function to extract information about a person from a JSON file.
Your task is to write a Python function extract_person_info that reads the JSON file and returns a dictionary containing the person's first name, last name, zip code, and work phone number.
- Sample JSON file:
/home/labex/project/person_info_sample.json
Requirements
- The function should take the file ABSOLUTE path of the JSON file as a parameter.
- The function should return a
dictionarywith the following keys:firstName: The person's first name.lastName: The person's last name.zipCode: The person's zip code.workNumber: The person's work phone number.
- The function should use the
jsonmodule to read the JSON file. - The function should use the
withstatement to open the file, to ensure that the file is properly closed after reading. - Your code should be well-documented and easy to understand.
Example
cd /home/labex/project
python person_info.py
Output:
{'firstName': 'John', 'lastName': 'Doe', 'zipCode': '12345', 'workNumber': '555-555-5678'}
Summary
Well done! You have now completed the Python challenge on the basics of using Python to process personal information.



