Python is a high-level programming language that translates human-readable instructions into actions a computer can perform. For the PCEP-30-02 exam, understanding how to install and run Python gives you the foundation to write, test, and debug your code. This chapter demystifies the environment setup so you can focus on learning the language itself rather than fighting with your computer.
Jump to a section
A simple way to picture Introduction to Python and Environment Setup
A recipe box is a physical container for organising handwritten recipe cards. It holds all the instructions you need to cook different meals, but it does not actually cook anything itself. You, the cook, are the one who reads the card, gathers the ingredients, and follows the steps to prepare the dish. The box is just the storage system.
Your computer works the same way. The hard drive is the recipe box — it stores files and programs. When you want to run a program, you open the box (click the file), and the computer's processor acts like you, the cook, reading and executing the instructions one by one. Python is like a set of pre-printed recipe cards in a special language. You write new cards (code), place them in the box, and then tell the computer to cook (run) them. The recipe box itself never changes the recipe — it just keeps it safe until you need it.
Setting up Python is like buying an empty recipe box and organising it so you can start adding your own cards. Without the box, your recipes get lost. Without Python installed, your computer cannot read or run Python instructions. The box gives you a home for your recipes; installing Python gives your computer the ability to understand and execute the Python language.
Python is a programming language, which means it is a set of rules and symbols that let you give instructions to a computer. Unlike machine language (made of zeros and ones) or assembly language, Python is designed to be easy for humans to read and write. The code you write in Python is saved in plain-text files with a .py extension — for example, 'program.py'. These files are called scripts or source code.
To run a Python script, your computer needs a special program called an interpreter. The interpreter reads your .py file line by line, translates each instruction into machine code that the processor understands, and executes it immediately. This is different from languages like C++ that require a compiler to translate the entire program before running it. Python's interpreter model makes it easier to test small pieces of code quickly.
There are two main ways to interact with the Python interpreter: the interactive shell and running a script file. The interactive shell, also called the REPL (Read-Eval-Print Loop), lets you type Python commands one at a time and see the result instantly. You launch the REPL by typing 'python' (or 'python3' on some systems) into your command line or terminal. For example, if you type 'print("Hello, world!")' and press Enter, the shell prints 'Hello, world!' back to you right away. This is fantastic for experimenting with small code snippets.
The second method is to write your full program in a .py file using a text editor (like Notepad, Sublime Text, or VS Code) and then run the entire file by typing 'python filename.py' in the terminal. The interpreter then reads the whole file from top to bottom and executes every line. Most real-world projects use this approach because you can save, edit, and rerun your code.
Installing Python is the first practical step. You download the installer from the official Python website (python.org). During installation on Windows, you must check the box that says 'Add Python to PATH'. This is critical because it tells your operating system where to find the Python interpreter when you type 'python' in the terminal. Without PATH set, you would have to type the full file path to the Python executable every time.
Once Python is installed, you can verify it by opening a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and typing 'python --version'. If the installation was successful, it prints the Python version number, such as 'Python 3.10.4'. The PCEP-30-02 exam expects you to know that Python 3 is the current major version — Python 2 is outdated and unsupported.
An Integrated Development Environment (IDE) is a tool that combines a text editor, a terminal, and other features into one window. IDLE is a simple IDE that comes bundled with Python. It has a shell window (like the REPL) and a file editor. For beginners, IDLE is perfectly adequate for the exam. More advanced IDEs like PyCharm or VS Code offer syntax highlighting (colouring different parts of code), automatic indentation, and debugging tools, but they are not required for PCEP-30-02.
Environment setup also involves understanding where your code lives. Your Python installation places the interpreter in a specific folder on your hard drive. When you run 'python', your operating system searches a list of folders called the PATH environment variable to find the interpreter. If you have multiple Python versions installed, you might need to use 'python3' instead of 'python' on some systems. The exam tests your awareness of these version commands.
Finally, you should know what happens when you run a Python script. The interpreter first checks the entire file for syntax errors — mistakes in the structure of the code, like a missing colon or an unmatched parenthesis. If it finds a syntax error, it stops immediately and shows an error message. If the syntax is correct, it executes the instructions one by one. If a runtime error occurs (like trying to divide by zero), the program crashes at that point. Understanding this flow — edit, save, run, debug — is the core cycle of Python programming.
Downloading the Installer
You go to python.org and download the latest Python 3 installer for your operating system (Windows, macOS, or Linux). The exam expects you to know the official source is python.org, not third-party sites.
Running the Installer with PATH Option
You double-click the installer and check the box 'Add Python to PATH' before clicking Install. This step ensures your operating system recognises the 'python' command in the terminal. Without it, typing 'python' produces an error.
Verifying the Installation
You open your terminal (Command Prompt on Windows, Terminal on macOS/Linux) and type 'python --version'. The system prints something like 'Python 3.12.1', confirming the interpreter is ready. This step is crucial before writing any code.
Writing Your First Script
You create a new file in a plain-text editor (like Notepad or IDLE), type 'print("Hello, world!")', and save it as 'hello.py'. The .py extension tells the operating system this file should be opened with the Python interpreter.
Running the Script from the Terminal
In the terminal, you navigate to the folder containing 'hello.py' using 'cd' (change directory) and then type 'python hello.py'. The interpreter reads the file, executes the print command, and displays 'Hello, world!' on the screen. If there is an error, you return to the editor to fix it and run again.
Imagine you have just joined a small marketing agency as a junior data assistant. Your manager asks you to write a Python script that reads a CSV file of customer email addresses and sends a personalised welcome message to each new subscriber. You have never used Python before, so your first task is to set up your environment.
Here is the step-by-step process you would follow:
First, you download the latest Python 3 installer from python.org. On your Windows laptop, you run the installer and make sure to check the 'Add Python to PATH' option. Without that, you will not be able to run Python from your command prompt later.
You open the Command Prompt (search 'cmd' in the Start menu) and type 'python --version' to confirm Python is installed correctly. The output shows 'Python 3.11.2'.
Next, you create a folder called 'email_project' on your desktop to store all your script files. This keeps your project organised and separate from other files.
You open Notepad++ (a free text editor) and write your script. You save the file as 'send_welcome.py' inside your project folder. The file extension .py tells your computer that this is a Python script.
To run the script, you open Command Prompt, navigate to the project folder by typing 'cd Desktop\email_project', and then type 'python send_welcome.py'. The interpreter reads your file, executes the code, and sends the emails.
If there is an error — for example, you misspelled a function name — the interpreter prints a traceback message showing the line number and type of error. You go back to Notepad++, fix the mistake, save the file, and run the script again. This loop of edit-run-debug continues until the script works perfectly.
In a real office, you might use a more advanced IDE like VS Code, but the fundamental steps remain the same: install Python, create a .py file, run it from the terminal, and fix errors based on the feedback. The IT professional's value comes from understanding how to resolve environment issues — like a missing PATH variable, incompatible Python versions, or dependencies (external libraries) that need to be installed. For the PCEP exam, you only need to master the basics of installation and running a script.
PCEP-30-02 exam objective 1.1 focuses on verifying that you understand the fundamental concepts of the Python environment. The exam will not ask you to install Python — that is a practical skill assumed before the exam. Instead, it tests your theoretical knowledge of what happens during installation and execution.
Key topics that appear in questions:
The difference between interactive mode and script mode. You might be shown a description and asked which mode it describes. For example, 'Which Python execution method reads and executes code one statement at a time?' Answer: interactive mode (REPL).
The purpose of the .py file extension. A common trap question: 'Can a Python script have any file extension?' Correct answer: no, Python scripts should use the .py extension for the interpreter to recognise them.
The role of the interpreter versus the compiler. They might ask: 'Does Python compile source code before execution?' The correct answer is no — Python uses an interpreter, but the interpreter does compile to bytecode internally (this is more advanced, but at entry level, you say it interprets).
The PATH environment variable. A trap question: 'What happens if Python is not added to PATH during installation?' The correct answer: you cannot run Python by typing 'python' in the terminal unless you specify the full path to the executable.
Version identification. Questions may ask: 'Which command displays the installed Python version?' Answer: 'python --version' or 'python -V'.
The difference between Python 2 and Python 3. The exam uses Python 3. A trick question might ask a Python 2-specific syntax (like print without parentheses). You must know that Python 3 requires parentheses in print statements.
Comment syntax. They love to test that '#' is used for single-line comments in Python. They may show code with '//' or '/* */' and ask if it is valid Python. It is not.
Exam traps to watch for:
Questions that mix up 'compile' and 'interpret'. Only know that Python is interpreted (line by line), not compiled (all at once before running).
Questions about IDLE. They might ask: 'Which of the following is a feature of IDLE?' Possible features include syntax highlighting, an interactive shell, and a file editor. Know that IDLE is part of the standard Python distribution.
Questions about running scripts. They might say: 'To run a script named test.py, you type ___' and give false options like 'run test.py' or 'execute test.py'. The correct command is 'python test.py'.
Questions about file extensions. A trap: 'Can you run a .txt file containing Python code?' No, because the interpreter looks for .py files by default, though you can technically rename and run it — but for the exam, the standard is .py.
Memorise these exact commands:
To check version: python --version or python -V
To run a script: python filename.py
To start interactive mode: python (with no filename)
To exit interactive mode: exit() or Ctrl+Z then Enter (Windows) / Ctrl+D (macOS/Linux)
Python is an interpreted language, meaning the interpreter reads and executes your code line by line, not all at once after a separate compilation step.
The interactive shell (REPL) lets you test Python commands one at a time, while script mode runs an entire .py file from start to finish.
When installing Python on Windows, you must tick the 'Add Python to PATH' checkbox to run Python from any terminal without typing the full file path.
To run a Python script from the terminal, type 'python filename.py' — the .py extension is the standard for Python source files.
The command 'python --version' (or 'python -V') displays the installed Python version and confirms the interpreter is accessible.
Python 2 is outdated and unsupported; the PCEP-30-02 exam tests Python 3 exclusively, which requires parentheses in print statements.
These come up on the exam all the time. Here's how to tell them apart.
Interactive Mode (REPL)
Executes one command at a time
Ideal for testing small code snippets
Starts by typing 'python' without a filename
Script Mode
Runs an entire .py file from start to finish
Best for full programs
Starts by typing 'python filename.py'
Python 2
Print statement does not need parentheses: print "Hello"
No longer maintained as of 2020
Some syntax differences in division and Unicode handling
Python 3
Print requires parentheses: print("Hello")
Actively developed and supported
Current default version for all new projects
IDE (e.g., PyCharm)
Includes integrated terminal, debugger, and code completion
Larger download and more resource-intensive
Provides syntax highlighting and error detection automatically
Plain Text Editor (e.g., Notepad)
Simple and fast to open
No built-in debugging or terminal
Requires manual save and terminal switching to test code
Mistake
You need an internet connection to write and run Python code.
Correct
Python is installed locally on your machine and runs entirely offline. You only need internet to download the installer or install additional packages from PyPI.
Newcomers often associate programming with online websites or cloud services, not realising that the Python interpreter runs on their own computer without any internet access.
Mistake
You must use a complex IDE like PyCharm to write Python; Notepad cannot produce working code.
Correct
Any plain-text editor — including Notepad, TextEdit (in plain-text mode), or even a terminal-based editor like nano — can write Python scripts. An IDE adds convenience but is not required.
Beginners often see professionals using sophisticated IDEs and assume they are mandatory, unaware that Python files are just plain text.
Mistake
Python is free to use for personal projects but you have to pay for a commercial licence to use it at work.
Correct
Python is open-source and completely free to use for any purpose — personal, educational, commercial, or government. There is no licence fee for writing or distributing Python code.
This confusion comes from experience with proprietary software like Microsoft Office or Adobe Photoshop, which do require paid licences for commercial use.
Mistake
If I get a syntax error, my code is broken forever and I need to reinstall Python.
Correct
A syntax error is just a mistake in your code's grammar — like a missing colon or parenthesis. You simply fix the line and rerun the script. Reinstalling Python does not fix code errors.
New users panic at error messages and assume the problem is with the software rather than their own typing, because they do not yet understand that error messages point to specific issues in the code.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
This usually means Python is not installed, or it was installed without ticking 'Add Python to PATH'. Check your installation and consider reinstalling with the PATH option ticked.
macOS comes with Python 2 pre-installed, but that version is outdated. You must install Python 3 from python.org. After installation, use 'python3' instead of 'python' to run your scripts if 'python' still points to Python 2.
Yes, tools like Replit or Google Colab run Python in your browser, but for the PCEP exam you should know the local installation process. The exam assumes you have Python installed on your own machine.
On some systems, 'python' points to Python 2 and 'python3' points to Python 3. On Windows with a fresh Python 3 install, 'python' usually works. Always use 'python3' on macOS/Linux to guarantee you are using Python 3.
On Windows, press Ctrl+Z followed by Enter. On macOS and Linux, press Ctrl+D. Alternatively, type 'exit()' and press Enter in any operating system.
Yes, treat any Python script from an unknown source as potentially dangerous because Python can execute system commands. Only run scripts you trust or have written yourself.
You've finished Introduction to Python and Environment Setup. Continue through the PCEP-30-02 study guide to build a complete picture of the exam.
Done with this chapter?