Table of Contents
Why is .py the Correct File Extension for Python Source Code?
Find out the standard file extension for saving a Python source file. Learn why using the .py extension is critical for the Python interpreter and IDEs to recognize and process your code correctly.
Question
Which file extension should you use to save a Python source file?
A. .p3
B. .txt
C. .pt
D. .py
Answer
D. .py
Explanation
.py is the standard extension for Python source files.
This extension is the standard convention that identifies a file as containing Python code. It allows the Python interpreter to execute the script. Additionally, code editors and Integrated Development Environments (IDEs) use the .py extension to enable language-specific features such as syntax highlighting, error checking, and code completion, which are essential for efficient development.
The other options are incorrect. The .p3 extension is not a recognized standard for Python files. A .txt file is a generic plain text file and would not be identified as an executable Python script by default. The .pt extension is typically used for saving trained models in PyTorch, a machine learning library, not for source code.
Python Basics: Learn, Apply & Build Programs certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the Python Basics: Learn, Apply & Build Programs exam and earn Python Basics: Learn, Apply & Build Programs certificate.