200-901 · Question #473
Refer to the exhibit. An astronomer creates a Python script named makeexoplanetapi.py to import external data for comparison with the department data. The astronomer changes the script after a…
The correct answer is B. --- makeexoplanetapi.py 2020-12-20 19:30:32 +++ makeexoplanetapi.py 2020-12-20 19:30:32 @@ -1,4 +1,5 @@ import csv import json import requests -app = Flask(__name__) +add app = Flask(__name__) response = requests.post('https://httpbin.org') with open("planets_exo.csv", "r", encoding="utf-8-sig") as f: exo = json.load(f) with open("exo_api.csv", "w", encoding="utf-8-sig") sub = json.dumps(sub, indent=4) print(sub) with open("exo_api.csv", "r", encoding="utf-8-sig") sub_list = json.load(sub) add sub = json.dumps(sub, indent=4) print(exo). A unified diff represents file changes with specific header lines, hunk range markers, and '-' or '+' prefixes on changed lines.
Question
Refer to the exhibit. An astronomer creates a Python script named makeexoplanetapi.py to import external data for comparison with the department data. The astronomer changes the script after a discussion with another astronomer. Which code snippet shows a unified diff of the script? A. B. C. D.
Exhibits
Options
- A--- makeexoplanetapi.py 2020-12-20 19:30:32
+++ makeexoplanetapi.py 2020-12-20 19:30:32
@@ -8,3 +8,3 @@
- response = requests.post('https://httpbin.org')
- app = Flask(name)
- @app.route('/planets_data') with open("planets_exo.csv", "r", encoding="utf-8-sig") as f: exo = json.load(f) with open("exo_api.csv", "w", encoding="utf-8-sig") f.write(str(reader)) print(exo)
- B--- makeexoplanetapi.py 2020-12-20 19:30:32 +++ makeexoplanetapi.py 2020-12-20 19:30:32 @@ -1,4 +1,5 @@ import csv import json import requests -app = Flask(name) +add app = Flask(name) response = requests.post('https://httpbin.org') with open("planets_exo.csv", "r", encoding="utf-8-sig") as f: exo = json.load(f) with open("exo_api.csv", "w", encoding="utf-8-sig") sub = json.dumps(sub, indent=4) print(sub) with open("exo_api.csv", "r", encoding="utf-8-sig") sub_list = json.load(sub) add sub = json.dumps(sub, indent=4) print(exo)
- C--- makeexoplanetapi.py 2020-12-20 19:30:32
+++ makeexoplanetapi.py 2020-12-20 19:30:32
@@ -1,7 +1,8 @@
import csv
import json
import requests
- response = requests.post('https://httpbin.org')
- app = Flask(name)
- @app.route('/planets_data') with open("planets_exo.csv", "r", encoding="utf-8-sig") as f: exo = json.load(f) with open("exo_api.csv", "w", encoding="utf-8-sig") f.write(str(reader)) print(exo)
- D--- makeexoplanetapi.py 2020-12-20 19:30:32
+++ makeexoplanetapi.py 2020-12-20 19:30:32
@@ -8,3 +8,3 @@
response = requests.post('https://httpbin.org')
- app = Flask(name)
- @app.route('/planets_data') with open("planets_exo.csv", "r", encoding="utf-8-sig") as f: exo = json.load(f) with open("exo_api.csv", "w", encoding="utf-8-sig") f.write(str(reader)) print(exo)
How the community answered
(36 responses)- A6% (2)
- B92% (33)
- C3% (1)
Why each option
A unified diff represents file changes with specific header lines, hunk range markers, and '-' or '+' prefixes on changed lines.
The hunk header '@@ -8,3 +8,3 @@' places the change at line 8, which does not correspond to where an import-block modification would appear, making the line numbering structurally incorrect.
A valid unified diff starts with '---' and '+++' file path headers, followed by '@@ -start,count +start,count @@' hunk headers, then uses '-' to prefix removed lines and '+' to prefix added lines, with unchanged context lines having no prefix. Option B correctly applies this structure, including the proper file headers and hunk notation showing the modified lines in the import block.
Although the file headers are present, the hunk range '@@ -1,7 +1,8 @@' and the indented lines marked as changed do not accurately reflect a top-level single-line replacement in the import section.
The diff incorrectly marks the Flask app initialization line as removed and the route decorator as added, reversing the actual direction of the change between the original and revised script.
Concept tested: Unified diff format for representing code changes
Source: https://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html
Topics
Community Discussion
No community discussion yet for this question.




