Drag steps to the numbered slots on the right, or tap a step then tap a slot.
PCEP Computer Programming and Python Fundamentals Practice Question
Arrange the steps to write and run a Python script from the command line in the correct order.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
Write the script in a text editor, save the file with a .py extension, open a terminal or command prompt, navigate to the directory containing the script, run the script using the Python interpreter.
The process involves creating the script, saving it, opening a terminal, navigating to its location, and executing it with the Python interpreter.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Write the script in a text editor, save the file with a .py extension, open a terminal or command prompt, navigate to the directory containing the script, run the script using the Python interpreter.
Why this is correct
This is the correct order because you must first create and save the script, then access the command line, change to the script's directory, and finally execute it with the Python interpreter.
- ✗
Write the script in a text editor, save the file with a .py extension, open a terminal or command prompt, run the script using the Python interpreter.
Why it's wrong here
This is incorrect because you must navigate to the directory containing the script before running it; otherwise, the command line will not find the script file unless it is in the current directory or the full path is provided.
- ✗
Write the script in a text editor, open a terminal or command prompt, run the script using the Python interpreter, save the file with a .py extension.
Why it's wrong here
This is incorrect because you cannot run a script that hasn't been saved yet; the file must exist before the interpreter can execute it.
- ✗
Write the script in a text editor, open a terminal or command prompt, navigate to the directory containing the script, run the script using the Python interpreter.
Why it's wrong here
This is incorrect because you must save the script file before running it; otherwise, the interpreter has no file to execute, and the code is not persisted.
Go deeper
Related to this question
About these practice questions
One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.