Python 3.14 and Exam Version Differences
PCEP-30-02 and PCAP-31-03 were written against a much older Python 3, and studying on a current interpreter quietly introduces disagreements. Most are harmless - better error messages than the exam will show you. One is not: Python 3.14 made legal a syntax that was an error for the whole of Python 3's history, and that older PCAP material teaches you to spot as broken. Every behaviour here was run on the machine and the release that changed it is named.
Start Here Guide 3 of 26 Beginner
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 15 min
- Reviewed23 August 2026
Written against the versions above. Captured on **Python 3.14.4**. Each item names the release that introduced the behaviour, so you can predict what your own interpreter will do. Where the exam's expected answer differs from 3.14's, that is stated outright.
| 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
- guide 2 - you should know your own
version_info. - No Python knowledge is needed; every sample is five lines or fewer.
-
The one that matters: except without parentheses
For the entire history of Python 3, catching two exception types required a tuple in parentheses.
except ValueError, TypeError:was a SyntaxError - it was Python 2 syntax, where the comma introduced the name to bind the exception object to, and removing it was one of the more visible Python 3 changes. Older PCAP material teaches you to recognise that line as broken, and "which of these is a syntax error?" is a question shape both exams use.Python 3.14 made it legal again, with the Python 3 meaning: a tuple of types, parentheses optional. PEP 758.
bash Example session cat > ~/py/except_tuple.py <<'PY'try: int("x")except ValueError, TypeError: print("caught - and the parentheses are gone")PYpython3 ~/py/except_tuple.pycaught - and the parentheses are goneExpected resultIt runs. No SyntaxError, no warning, and the
exceptcatches normally.Success conditionYou have seen the one 3.14 change that can cost you a mark.
-
Error messages now tell you the answer
The exams ask you to identify what a broken program raises. On a current interpreter the traceback often names the fix as well, which is a much gentler experience than the one you will get in the exam window.
NameErrorsuggestions arrived in Python 3.10. The interpreter compares the unknown name against the names in scope and offers the closest.bash Example session cat > ~/py/typo.py <<'PY'length = 5print(lenght)PYpython3 ~/py/typo.pyTraceback (most recent call last): File "/home/sysadmin/py/typo.py", line 2, in <module> print(lenght) ^^^^^^NameError: name 'lenght' is not defined. Did you mean: 'length'?[exit 1]Expected result
NameError: name 'lenght' is not defined. Did you mean: 'length'?Success conditionYou know the suggestion is a 3.10+ courtesy, not part of the exception name.
-
The same courtesy for attributes and modules
AttributeErrorsuggestions arrived in Python 3.12, and they cover module attributes as well as object attributes. PCAP section 1 is themath,randomandplatformmodules, so this is the message you will see most while practising - and the one that will most obviously be missing when it counts.bash Example session cat > ~/py/attr.py <<'PY'import mathprint(math.sqr(4))PYpython3 ~/py/attr.pyTraceback (most recent call last): File "/home/sysadmin/py/attr.py", line 2, in <module> print(math.sqr(4)) ^^^^^^^^AttributeError: module 'math' has no attribute 'sqr'. Did you mean: 'sqrt'?[exit 1]Expected result
AttributeError: module 'math' has no attribute 'sqr'. Did you mean: 'sqrt'?Success conditionYou can name the exception type without leaning on the suggestion.
-
return in a finally block is now a warning
finallyruns whatever happens, and areturninside it discards any value or exception thetrywas carrying. That has always been true and is examinable under PCAP objective 2.1 - a question that shows this and asks what the function returns expects the answer2, not1.Python 3.14 now warns about it. PEP 765.
bash Example session cat > ~/py/finally_return.py <<'PY'def f(): try: return 1 finally: return 2 print(f())PYpython3 ~/py/finally_return.py/home/sysadmin/py/finally_return.py:5: SyntaxWarning: 'return' in a 'finally' block return 22Expected resultA
SyntaxWarningnaming line 5, and then the answer:2.Success conditionThe behaviour is unchanged - only the warning is new.
-
Very large integers no longer print
PCEP objective 1.3 covers integers and numeral systems, and the usual demonstration of Python's unbounded integers is to compute something absurd and print it. On any Python 3.11 or newer that fails, because converting an
intto astris capped at 4300 digits by default - a denial-of-service fix, since the conversion is quadratic in the number of digits.bash Example session python3 -c 'print(len(str(2 ** 20000)))'Traceback (most recent call last): File "<string>", line 1, in <module> print(len(str(2 ** 20000))) ~~~^^^^^^^^^^^^ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit[exit 1]python3 -c 'print(int("1" * 5000))'Traceback (most recent call last): File "<string>", line 1, in <module> print(int("1" * 5000)) ~~~^^^^^^^^^^^^ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 5000 digits; use sys.set_int_max_str_digits() to increase the limit[exit 1]Expected result
ValueError: Exceeds the limit (4300 digits) for integer string conversion- in both directions.Success conditionYou know the arithmetic is unbounded and only the text conversion is capped.
-
Invalid escape sequences warn now and will break later
PCEP objective 3.4 and PCAP section 3 both cover string literals and escapes.
\nand\tare real escapes;\dis not, and Python has historically passed unknown escapes through unchanged. Since Python 3.12 that is aSyntaxWarning, and the message says plainly that it will stop working.bash Example session python3 -c 'print("\d")'<string>:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.\dpython3 -c 'print(r"\d")'\dExpected resultA warning and then
\d- followed by the raw-string form, which prints the same thing silently.Success conditionYou can explain why the second command is the correct way to write the first.
-
What has not changed
It is as useful to know what is stable, because a great deal of advice online claims otherwise. Every row below is printed by the script, not asserted here:
| Claim you will meet | The line that answers it | |---|---| | "Integer division changed" |
floored division| | "printneeds no parentheses in newer Python" |print is a| | "String methods were renamed or removed" |public str methods,str.decode exists| | "platform.linux_distribution()is back" |linux_distribution| | "Dictionaries are unordered" |dict keeps insertion|bash Example session cat > ~/py/stable.py <<'PY'import platformprint("floored division :", -7 // 2)print("print is a :", type(print).__name__)print("public str methods :", len([m for m in dir(str) if not m.startswith("_")]))print("str.decode exists :", hasattr(str, "decode"))print("linux_distribution :", hasattr(platform, "linux_distribution"))print("dict keeps insertion :", list({"z": 1, "a": 2, "m": 3}))PYpython3 ~/py/stable.pyfloored division : -4print is a : builtin_function_or_methodpublic str methods : 47str.decode exists : Falselinux_distribution : Falsedict keeps insertion : ['z', 'a', 'm']Expected result-4, a built-in function, 47 methods, no
decode, nolinux_distribution, and['z', 'a', 'm']in the order written.Success conditionYou can separate real changes from folklore.
-
What to do with all of this
Practise on whatever Python you have, and treat every "Did you mean:" as a hint you will not get on the day. Read the exception type off the last line of a traceback first, before the message, because the type is what questions ask for and it is the one part that has not changed.
The one item to actively unlearn is the unparenthesised
except, because there 3.14 and the exam genuinely disagree. Everything else on this page is a message improvement, a new warning about unchanged behaviour, or a limit on a conversion neither blueprint mentions.If you are choosing an interpreter from scratch, 3.12 or newer gives you the better error messages while you learn, and the single 3.14 syntax difference is one fact to remember rather than a reason to install something older.
The orientation track ends here. guide 4 starts PCEP block 1.
bash Example session python3 --versionPython 3.14.4Expected resultWhatever your interpreter reports - the point is that you know which one it is.
Success conditionYou know which differences to expect from your own Python, and which single one to answer against.
Troubleshooting
except ValueError, TypeError:runs on your machine but a question calls it a syntax error.Why: PEP 758 made the unparenthesised form legal in Python 3.14. The exam predates it.
Fix:Answer that it is a syntax error, and write
except (ValueError, TypeError):in your own code - correct on every release.ValueError: Exceeds the limit (4300 digits)printing a large power.Why: Since 3.11 the int-to-str conversion is capped, not the arithmetic.
Fix:Nothing is wrong. Use
sys.set_int_max_str_digits(0)to lift the cap if you want the digits, or compare the integers without printing them.SyntaxWarning: "\d" is an invalid escape sequence.Why: An unknown escape in a normal string literal - a warning since 3.12.
Fix:Make it a raw string:
r"\d". Same two characters, no warning, and it will keep working when the warning becomes an error.An error message on your machine does not match the one in a practice question.
Why: Message text improved across 3.10 to 3.14; the exception types did not change.
Fix:Compare the exception type, not the sentence.
NameErrorisNameErrorwhether or not it suggests a spelling.Older notes say dictionaries have no order.
Why: True before Python 3.7. Guaranteed insertion order since.
Fix:Rely on insertion order. See guide 16 for what the exam expects, which is not always the same as what is true.