220-1102 Question 788
Single answer.pyA Windows 11 user reports that double-clicking a .py file no longer runs the company’s inventory script. Instead, the file opens in a text editor. The script worked last week, and the user says Python is still installed. You need to restore normal behavior with the least disruptive fix so the user can run Python scripts by double-clicking them again. What should you do first?
- A
Change the default app for .py files back to the Python launcher or python.exe in Default Apps
- B
Rename the file from .py to .exe so Windows treats it as an executable program
- C
Run sfc /scannow to repair corrupted Windows system files associated with Python
- D
Disable User Account Control so script execution is no longer blocked
Show answer and explanation
Correct answer: A
Explanation
This scenario tests practical troubleshooting of file associations in Windows, which is relevant to A+ Core 2 objectives around operating systems, application behavior, and basic script-related support tasks. A .py file is a Python script file, and on Windows it typically runs through the Python launcher (py.exe) or the Python interpreter when the file association is configured correctly. If the file suddenly opens in a text editor, the most likely cause is that the default app for .py was changed, often after the user selected 'Open with' and chose an editor. Best practice is to start with the least disruptive, most symptom-focused fix: verify and correct the file association in Windows Settings > Apps > Default apps or via the file's Open With settings. Python documentation for Windows commonly references the Python launcher (py.exe) as the preferred way to launch scripts, and Microsoft Windows documentation covers managing default apps and file associations. More invasive steps such as SFC or disabling security controls are not appropriate first-line fixes for this issue.
- A. Correct.
Correct. On Windows, if a .py file opens in a text editor when double-clicked, the file association for the .py extension has likely been changed. Restoring the default app association to the Python launcher (py.exe) or the Python interpreter (python.exe) is the least disruptive first step. This directly addresses the symptom without making unnecessary system-wide changes.
- B. Incorrect.
Incorrect. Renaming a Python script to .exe does not convert it into a Windows executable. The file would still contain Python source code and would not run as a native executable. This reflects a common misconception that changing a file extension changes the underlying file format.
- C. Incorrect.
Incorrect. System File Checker repairs protected Windows system files, not third-party application file associations in most cases. Although it is a valid troubleshooting tool for OS corruption, it is not the best first step for a changed .py association when Python is still installed and the issue is isolated to how the file opens.
- D. Incorrect.
Incorrect. User Account Control is not the reason a .py file opens in a text editor. UAC controls elevation prompts and administrative permissions, not the default application assigned to a file extension. Disabling UAC would reduce system security and would not appropriately address the reported symptom.