Python Practice Environment
Every other path on this site needs a cluster or a pair of managed hosts. This one needs a shell with Python 3 in it. That is worth saying explicitly rather than leaving a reader to discover it, because it changes how you should study: you can follow every guide here on the laptop you are reading it on, and the only thing worth checking first is which interpreter you have.
Start Here Guide 2 of 26 Beginner
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 8 min
- Reviewed23 August 2026
Written against the versions above. The captures in this path came from **Python 3.14.4** on Ubuntu 26.04. Any Python 3.8 or newer will run almost everything here, but error messages improved a great deal between 3.10 and 3.14 and several of them appear verbatim in these guides - see {{guide:python-314-versus-the-syllabus}}.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
- A shell. Linux, macOS or WSL are all fine.
- Python 3. Nothing else is installed anywhere in this path.
-
The interpreter this guide assumes
Every command in this guide was run on RUNNER01 with the interpreter below. There is nothing to install and no service to configure - both exams test the language itself, so any shell with Python 3 will do, including your own laptop.
One thing is worth confirming rather than assuming: the exact interpreter version. PCEP-30-02 and PCAP-31-03 were written well before Python 3.14, and a handful of behaviours have changed since - error message wording most visibly. Where a capture on this page shows something that would have looked different on an older interpreter, the guide says which release changed it.
Scratch files live in
~/py, and every guide that writes one removes it. Nothing in this path needssudo, and nothing it does can affect the rest of the machine.bash Example session python3 --versionPython 3.14.4python3 -c "import sys; print(sys.executable)"/usr/bin/python3python3 -c "import sys; print(sys.version)"3.14.4 (main, Jun 18 2026, 14:25:02) [GCC 15.2.0]mkdir -p ~/py && ls -d ~/py/home/sysadmin/pyExpected resultPython 3.14.4, and a directory to write scratch files in.
Success conditionYour interpreter matches the one every output on this page came from.
-
Why there is only one machine
The lab table above has one row, and that is not a simplification.
PCEP and PCAP examine the language. Between them the two blueprints cover literals, operators, control flow, four collection types, functions, scope, exceptions, modules, classes, comprehensions, lambdas, closures and file I/O. Not one of those needs a service running, a port open, a second host to talk to, or root. Everything in this path is a file in a directory and an interpreter reading it.
That has three consequences worth acting on.
You do not need this machine. Any Python 3 gives the same answers. The server table exists so you can see which interpreter produced the output on the page, not because the box is special.
Nothing here needs
sudo. No guide in this path installs a package, edits a file outside your home directory, or starts anything. If a step ever seems to want root, it is a mistake - report it.Scratch files are disposable. Every guide that writes one names it, uses it and removes it.
~/pyis the only directory this path touches, and it is empty again at the end of every page.bash Example session mkdir -p ~/py && ls -d ~/py/home/sysadmin/pyExpected resultA directory under your home. That is the entire lab.
Success conditionYou have somewhere to put scratch files, and nothing else to prepare.
-
The one thing worth checking: which interpreter you have
This is the check that actually matters, because two guides in this path show output that a different interpreter would print differently.
sys.versiongives the full string, including the build date and the compiler - useful when comparing against a colleague's box.sys.version_infogives the same thing as a tuple you can compare in code, and it is the form worth remembering: PCAP objective 1.4 asks aboutplatform.python_version_tuple(), which returns the same three numbers as strings rather than integers.bash Example session python3 -c "import sys; print(sys.version)"3.14.4 (main, Jun 18 2026, 14:25:02) [GCC 15.2.0]python3 -c "import sys; print(sys.version_info)"sys.version_info(major=3, minor=14, micro=4, releaselevel='final', serial=0)Expected resultA version string, then a named tuple -
major=3, minor=14, micro=4here.Success conditionYou can state your interpreter version exactly, in both forms.
-
How code is run in these guides
Every code sample in this path follows the same two-command shape, so you can copy either half and know what it does. The quoted
<<'PY'matters: it stops the shell touching$, backticks or backslashes inside the code, which matters the moment a sample contains a string like"\n".bash Example session cat > ~/py/hello.py <<'PY'name = "PCEP"print("hello,", name)PYpython3 ~/py/hello.pyhello, PCEPExpected result
hello, PCEP.Success conditionYou can run any sample in this path.
-
Why a file rather than the prompt or -c
Because of what a traceback says.
Run from a file, a traceback names the file and the line for every frame - here the call site on line 5 and the division on line 2. That is most of what a traceback is for, and several guides in this path are built on reading one.
The same failure through
python3 -creportsFile "and a line number that refers to nothing you can open. Typed at the interactive" >>>prompt it reportsFile ", which is no better." bash Example session cat > ~/py/boom.py <<'PY'def middle(): return 1 / 0 print(middle())PYpython3 ~/py/boom.pyTraceback (most recent call last): File "/home/sysadmin/py/boom.py", line 5, in <module> print(middle()) ~~~~~~^^ File "/home/sysadmin/py/boom.py", line 2, in middle return 1 / 0 ~~^~~ZeroDivisionError: division by zero[exit 1]python3 -c 'print(1 / 0)'Traceback (most recent call last): File "<string>", line 1, in <module> print(1 / 0) ~~^~~ZeroDivisionError: division by zero[exit 1]Expected resultTwo frames with a real path and real line numbers, then the same exception reported against
<string>.Success conditionYou can see why the file form is used for anything longer than one line.
-
If you are on Windows without WSL
Every code sample in this path is pure Python and runs unchanged under
pyorpythonon Windows. What will not run is thecat > file <<'PY'wrapper around it, which is a POSIX shell idiom.Paste the code into a file with any editor and run
python name.pyinstead. The output is identical, with one cosmetic exception: paths in tracebacks appear asFile "C:\\Users\\you\\py\\boom.py"rather than/home/sysadmin/py/boom.py.There is also nothing to install beyond Python itself. No virtual environment is needed anywhere in this path, because no guide installs a package -
venvandpipare good practice in real work and are examined by neither exam. The one place the module system *is* examined is writing your own module and package, and that is plain files onsys.pathwith no tooling at all - guide 8.bash Example session python3 -c "import sys; print(sys.executable)"/usr/bin/python3Expected resultThe interpreter path. On Windows this is a
C:\...\python.exeinstead.Success conditionYou know what differs on Windows, and that it is only the shell around the code.
Troubleshooting
python: command not found, butpython3works.Why: Most Linux distributions ship no unversioned
pythonon PATH.Fix:Use
python3everywhere, as this path does. On Ubuntu thepython-is-python3package adds the alias if you want it; nothing here needs it.A heredoc sample produced mangled code in the file.
Why: The delimiter was written unquoted -
<rather than <<'PY'.Fix:Quote it. Unquoted, the shell expands
$nameand collapses backslashes inside the body before Python ever sees it, so"\n"arrives as a literal newline.A traceback says
File "<stdin>"and the line number makes no sense.Why: The code was pasted into the interactive prompt, or piped in on standard input.
Fix:Write it to a file and run the file. The line numbers then match what you can actually open and edit.
Considering installing an older Python to match the exam.
Why: Reading that the syllabus predates the current release.
Fix:Not worth it. Every difference is listed in guide 3, and all but one make a newer interpreter more helpful rather than less. The one exception is a single fact to remember, not a reason to downgrade.