PCEP-30-02 — Python Institute PCEP - Certified Entry-Level Python Programmer Quick Review

Quick Review for the Python Institute PCEP - Certified Entry-Level Python Programmer (PCEP-30-02), focused on core Python syntax, control flow, collections, functions, exceptions, and common exam traps.

Quick Review purpose

This Quick Review is for candidates preparing for the Python Institute PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) exam from Python Institute. It is designed to refresh the Python fundamentals that often appear in entry-level certification questions before you move into topic drills, mock exams, and detailed explanations.

Use it as an IT Mastery practice guide: review the rules, identify weak spots, then test yourself with original practice questions in a question bank. The goal is not to memorize isolated syntax, but to predict what Python will do in short code fragments.

What to review first

For PCEP-30-02, prioritize these areas:

AreaWhat to know coldTypical exam trap
Program structureStatements, indentation, comments, basic execution flowTreating indentation as optional
Data typesint, float, str, bool, NoneConfusing display form with stored value
OperatorsArithmetic, comparison, Boolean, assignmentPrecedence and integer division
Input/outputprint(), input(), type conversionForgetting input() returns a string
Control flowif / elif / else, while, for, break, continue, else on loopsMisreading loop termination conditions
CollectionsLists, tuples, dictionaries, stringsMutability, indexing, slicing boundaries
FunctionsDefining, calling, parameters, return values, scopeConfusing print() with return
ExceptionsBasic try / except, common exception typesCatching too broadly or expecting errors at the wrong time
Modules and built-insImport basics and common built-in functionsNamespace and call syntax mistakes

Python execution basics

Python executes code mostly from top to bottom. The exam often uses short snippets where one line changes the meaning of the next.

ConceptReview point
Case sensitivityName, name, and NAME are different identifiers
IndentationDefines code blocks after if, loops, functions, and exception handlers
Comments# starts a single-line comment
Statement orderA variable must be assigned before it is used
Dynamic typingA variable name can later refer to a value of a different type
ErrorsSome errors occur before execution; others occur only when the line runs

Common mistake: assuming Python “declares” variable types. In Python, names refer to objects; the object has the type.

Literals, variables, and basic types

Core types

TypeExampleKey behavior
int7, -3, 0Whole numbers; unlimited practical precision subject to memory
float3.14, 2.0Approximate decimal values
str"Python", 'PCEP'Immutable sequence of characters
boolTrue, FalseSubclass-like behavior with numeric contexts, but treat as logical values
NoneTypeNoneRepresents absence of a value

Type conversion traps

ExpressionResult ideaTrap
int("10")Converts string to integerFails if the string is not a valid integer literal
float("3.5")Converts string to floatResult is numeric, not text
str(10)Converts integer to string"10" is not the same as 10
bool(0)FalseNonzero numbers are usually True
bool("")FalseNon-empty strings are usually True, even "False"

High-yield rule: input() always returns a string. Convert before numeric comparison or arithmetic.

Example decision:

  • age = input() gives a string.
  • age + 1 is an error unless age is converted.
  • int(age) + 1 performs numeric addition if the input is valid.

Operators and precedence

Arithmetic operators

OperatorMeaningExample result
+Addition or string/list concatenation2 + 3 gives 5; "a" + "b" gives "ab"
-Subtraction5 - 2 gives 3
*Multiplication or repetition3 * 4 gives 12; "ha" * 3 gives "hahaha"
/True division5 / 2 gives 2.5
//Floor division5 // 2 gives 2; -5 // 2 gives -3
%Modulo5 % 2 gives 1
**Exponentiation2 ** 3 gives 8

Operator precedence to remember

Higher priority firstNotes
ParenthesesAlways evaluate first
**Exponentiation has high precedence
Unary +, -Watch -2 ** 2; exponentiation binds before unary minus
*, /, //, %Same level, left to right
+, -Same level, left to right
Comparisons<, <=, >, >=, ==, !=
notBoolean negation
andBoolean conjunction
orBoolean disjunction

Common traps:

  • 2 + 3 * 4 is 14, not 20.
  • (2 + 3) * 4 is 20.
  • 5 / 2 is 2.5, not 2.
  • 5 // 2 is 2.
  • -5 // 2 floors downward to -3, not toward zero.
  • 2 ** 3 ** 2 is evaluated right-associatively: 2 ** (3 ** 2).

Comparisons and Boolean logic

Comparisons

OperatorMeaning
==Equal value
!=Not equal value
<, <=Less than, less than or equal
>, >=Greater than, greater than or equal
isSame object identity, not general equality
inMembership test

For entry-level questions, prefer == for value comparison. Do not use is to compare ordinary numbers or strings unless the question is specifically about identity.

Truthiness

ValueBoolean interpretation
0, 0.0False
""False
[], (), {}False
NoneFalse
Nonzero numbersTrue
Non-empty strings/collectionsTrue

Trap: "0" is a non-empty string, so it is True in Boolean context.

Boolean short-circuiting

ExpressionWhat Python may skip
A and BIf A is false, B is not evaluated
A or BIf A is true, B is not evaluated

This matters when the skipped expression would call a function, modify a variable, or raise an exception.

Input and output

print()

print() displays values. It does not return the displayed value; its return value is None.

High-yield options:

  • print(a, b) separates values with a space by default.
  • sep= changes the separator.
  • end= changes what is printed after the output, defaulting to a newline.

Common examples:

  • print("A", "B") displays A B.
  • print("A", "B", sep="-") displays A-B.
  • print("A", end="") does not move to a new line after A.

input()

input() reads text and returns a string.

GoalCorrect pattern
Read textname = input()
Read integern = int(input())
Read floatx = float(input())
Compare numeric inputConvert first, then compare

Common mistake: input() does not automatically parse numbers.

Conditional logic

if, elif, else

Use if for the first condition, elif for additional alternatives, and else as the fallback.

Key rules:

  • Only the first true branch in an if / elif chain runs.
  • else has no condition.
  • Indentation determines what belongs to the branch.

Common trap:

  • Multiple separate if statements can all run.
  • An if / elif / else chain runs at most one branch.
StructureBehavior
if A: ... if B: ...Both tests are independent
if A: ... elif B: ...Test B only if A is false
if A: ... else: ...Exactly one branch runs

Nested conditions

Read nested code by indentation, not by visual closeness. Exam questions may align an else with an inner if, not the outer one.

Decision rule:

  1. Match each else to the nearest preceding if at the same indentation level.
  2. Evaluate outer conditions first.
  3. Enter only the block whose condition permits it.

Loops

while loops

A while loop repeats while its condition is true.

Review points:

  • If the condition is false initially, the body does not run.
  • A loop variable must usually be updated inside the loop.
  • A missing update can create an infinite loop.
  • break exits the nearest loop.
  • continue skips to the next iteration check.

Common trace method:

  1. Write the initial variable values.
  2. Check the loop condition.
  3. Execute the body line by line.
  4. Record updates.
  5. Repeat until the condition fails or break runs.

for loops

A for loop iterates over an iterable such as a string, list, tuple, dictionary, or range().

PatternMeaning
for ch in "abc"Iterates over characters: a, b, c
for item in [10, 20]Iterates over list elements
for i in range(3)Produces 0, 1, 2
for i in range(2, 5)Produces 2, 3, 4
for i in range(1, 6, 2)Produces 1, 3, 5

range() traps

ExpressionValues
range(5)0, 1, 2, 3, 4
range(1, 5)1, 2, 3, 4
range(5, 1, -1)5, 4, 3, 2
range(1, 5, -1)No values
range(1, 5, 0)Error: zero step is invalid

The stop value is excluded.

Loop else

Python loops can have an else block. It runs if the loop finishes normally. It does not run if the loop exits with break.

SituationLoop else runs?
Loop condition becomes false naturallyYes
for loop exhausts iterableYes
break executesNo
continue executes but loop later finishes normallyYes

This is a frequent candidate mistake because loop else is not the same as if / else.

Strings

Strings are immutable sequences.

Indexing and slicing

ExpressionMeaning
s[0]First character
s[-1]Last character
s[1:4]Characters at indexes 1, 2, 3
s[:3]From start through index 2
s[3:]From index 3 to end
s[::-1]Reversed copy

If s = "Python":

ExpressionResult
s[0]"P"
s[-1]"n"
s[1:4]"yth"
s[:2]"Py"
s[2:]"thon"

Common traps:

  • Indexing outside the string raises an error.
  • Slicing outside the string usually does not raise an error; it adjusts to valid boundaries.
  • Strings cannot be changed in place: s[0] = "J" is invalid.
  • s.upper() returns a new string; it does not modify s.

String operators and methods

OperationReview point
+Concatenates strings
*Repeats strings
inChecks substring membership
len(s)Returns number of characters
s.lower() / s.upper()Return transformed copies
s.strip()Returns copy with surrounding whitespace removed
s.split()Returns a list of substrings
"sep".join(list)Joins strings with separator

Trap: "10" + "5" gives "105", not 15.

Lists

Lists are mutable ordered collections.

List basics

OperationMeaning
lst[0]First element
lst[-1]Last element
lst[1:3]Slice copy of selected elements
lst.append(x)Adds x to the end
lst.insert(i, x)Inserts x at index i
lst.pop()Removes and returns last element
lst.pop(i)Removes and returns element at index i
del lst[i]Deletes element at index i
len(lst)Number of elements
x in lstMembership test

Mutability and aliasing

If two variables refer to the same list, changing through one name affects the other.

PatternResult
b = ab and a refer to the same list
b = a[:]b is a shallow copy
b = list(a)b is a shallow copy
a.append(5)Mutates the list in place

Common trap: methods such as append(), sort(), and reverse() modify the list and return None.

Sorting

Method/functionBehavior
lst.sort()Sorts the list in place; returns None
sorted(lst)Returns a new sorted list
lst.reverse()Reverses in place; returns None
reversed(lst)Produces a reverse iterator

Candidate mistake: assigning lst = lst.sort() makes lst become None.

Tuples

Tuples are immutable ordered collections.

ConceptReview point
Creation(1, 2, 3)
Single-element tuple(1,), not (1)
IndexingSame style as lists
ImmutabilityCannot assign to t[0]
Can contain mutable objectsThe tuple is immutable, but a contained list may still be mutated

Common trap: parentheses alone do not make a tuple; the comma matters for a single-element tuple.

Dictionaries

Dictionaries store key-value pairs and are mutable.

OperationMeaning
d[key]Retrieves value for key; error if missing
d[key] = valueAdds or updates a key-value pair
key in dChecks whether key exists
d.get(key)Returns value or None if missing
d.get(key, default)Returns value or default if missing
del d[key]Deletes key-value pair
d.keys()View of keys
d.values()View of values
d.items()View of key-value pairs

Common traps:

  • in checks keys, not values.
  • Keys must be hashable; lists cannot be dictionary keys.
  • Accessing a missing key with d[key] raises an error.
  • Assigning to an existing key overwrites the old value.

Functions

Function definition and call

A function definition creates a callable object. The body runs only when the function is called.

Key rules:

  • Parameters are names used inside the function.
  • Arguments are values passed during the call.
  • return sends a value back to the caller and exits the function.
  • If no return runs, the function returns None.

Common mistake: confusing displayed output with returned value.

Function behaviorEffect
Uses print(x)Displays x, returns None unless another return exists
Uses return xGives x back to the caller
Reaches end without returnReturns None
Executes return inside a loopLeaves the entire function, not just the loop

Parameters and arguments

TypeExample ideaReview point
Positionalf(1, 2)Matched by order
Keywordf(a=1, b=2)Matched by name
Defaultdef f(x=0):Used when argument omitted
Mixedf(1, b=2)Positional arguments generally come before keyword arguments

Common traps:

  • A required parameter without a default must receive an argument.
  • Do not place a non-default parameter after a default parameter in a function definition.
  • Mutable default arguments can preserve changes between calls; for entry-level review, recognize this as risky behavior.

Scope

Scope ideaMeaning
Local variableAssigned inside a function; normally visible only there
Global variableDefined at top level
Name lookupPython looks for local names before outer/global names
Assignment inside functionCreates or updates a local name unless explicitly declared otherwise

Candidate mistake: assuming assignment inside a function automatically changes a global variable.

Exceptions

Basic exception handling

try / except lets code handle runtime errors.

Review points:

  • Code in try runs first.
  • If a matching exception occurs, the matching except block runs.
  • If no exception occurs, except blocks are skipped.
  • Code after the whole structure continues unless the exception is unhandled or the program exits.

Common exception types to recognize:

ExceptionTypical cause
ZeroDivisionErrorDivision or modulo by zero
ValueErrorCorrect type but invalid value, such as int("abc")
TypeErrorOperation on incompatible types, such as "3" + 4
IndexErrorList/string/tuple index out of range
KeyErrorMissing dictionary key
NameErrorName used before being defined

Exception trap patterns

PatternWhat to watch
Error before tryIt will not be caught by that try
Error after try / exceptIt must be handled separately
Multiple except blocksFirst matching handler runs
Broad except firstMore specific later handlers may never run
else with tryRuns only if no exception occurs
finallyRuns whether or not an exception occurred

For the exam, focus on identifying whether an error occurs, where it occurs, and whether the provided handler catches it.

Modules and imports

Python code can use modules to organize reusable functionality.

Import formHow to use it
import mathCall with math.sqrt(9)
from math import sqrtCall with sqrt(9)
import math as mCall with m.sqrt(9)
from math import *Imports many names directly; can obscure where names came from

Common traps:

  • After import math, sqrt(9) alone is not available unless imported directly.
  • After from math import sqrt, math.sqrt(9) is not available unless math was also imported.
  • Aliases replace the original module name in that namespace: after import math as m, use m, not necessarily math.

Built-in functions to recognize

FunctionPurposeTrap
len(x)Length of a sequence or collectionDoes not work on plain integers
type(x)Returns the type objectUseful for reasoning, not usually for production branching
int(x)Converts to integer when validTruncates floats toward zero
float(x)Converts to float when validMay produce approximate values
str(x)Converts to stringEnables concatenation with other strings
bool(x)Converts using truthiness"False" becomes True
range()Produces integer sequence for iterationStop value excluded
sum()Adds numeric iterable valuesFails on mixed incompatible values
min() / max()Finds smallest/largestComparisons must be valid
print()Displays outputReturns None
input()Reads textAlways returns str

High-yield tracing checklist

When a question asks “What is the output?” or “What is the result?”, use this order:

  1. Check for syntax or indentation problems. If code cannot parse, execution never starts.
  2. Record initial assignments. Track variable values carefully.
  3. Apply type rules. Decide whether operations are numeric, string, list, or invalid.
  4. Apply precedence. Parentheses first, then operators.
  5. Trace branches. In an if / elif chain, only the first true branch runs.
  6. Trace loops one iteration at a time. Update loop variables after each body execution.
  7. Watch mutation. Lists and dictionaries may change in place.
  8. Separate print() from return. Output and return values are not the same.
  9. Check exception location. Determine whether the error is inside a matching try.
  10. Confirm final output formatting. Spaces, newlines, separators, and end= matter.

Common candidate mistakes

MistakeCorrect thinking
Treating input() as numericIt returns str; convert explicitly
Forgetting indentation defines blocksCount indentation levels before tracing
Confusing / and /// gives float-style true division; // floors
Assuming slices include the stop indexStop index is excluded
Assuming list methods return the changed listMany in-place methods return None
Using is for ordinary equalityUse == for value comparison
Forgetting strings are immutableString methods return new strings
Thinking tuple parentheses always matterFor single-element tuples, the comma matters
Assuming dictionary in checks valuesIt checks keys
Confusing break and continuebreak exits loop; continue skips to next iteration
Missing loop else behaviorLoop else runs only without break
Assuming print() returns printed textprint() returns None
Ignoring short-circuit behaviorRight side may not run
Overlooking aliasingTwo names can refer to the same mutable object

Quick decision tables

“Will this modify the original object?”

OperationModifies original?
lst.append(x)Yes
lst.sort()Yes
lst.reverse()Yes
lst + [x]No, creates a new list
s.upper()No, strings are immutable
s.replace(a, b)No, returns a new string
d[key] = valueYes
t[0] = xInvalid for tuple

“Will this raise an error?”

SituationLikely result
"3" + "4""34"
"3" + 4TypeError
int("4") + 37
int("4.5")ValueError
float("4.5")4.5
[1, 2][5]IndexError
[1, 2][1:5]Valid slice
{"a": 1}["b"]KeyError
{"a": 1}.get("b")None
10 / 0ZeroDivisionError

“Which branch runs?”

Code shapeResult
if A and A trueif block runs
if A false, elif B trueelif block runs
if A false, all elif falseelse block runs if present
Separate if statementsEach condition is tested independently
Nested ifInner condition tested only if outer path is entered

Practice strategy after this review

After reading this page, move directly into original practice questions rather than rereading theory repeatedly. A good IT Mastery question bank should help you:

  • Drill one topic at a time, such as operators, loops, lists, functions, or exceptions.
  • Practice short code-tracing questions under time pressure.
  • Review detailed explanations for both correct and incorrect choices.
  • Identify whether mistakes come from syntax, type rules, control flow, or output formatting.
  • Revisit weak areas with targeted topic drills before attempting full mock exams.

For Python Institute PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) preparation, the most efficient next step is to complete a small set of topic drills, review every explanation carefully, and then take a mixed mock exam to confirm that you can apply the rules without prompts.

Continue in IT Mastery

Use this Quick Review as a final concept map, then move into IT Mastery for focused topic drills, mixed practice sets, timed mock exams, and detailed explanations. The practice questions are original IT Mastery practice items; they are not official Python Institute questions, copied live-exam content, or exam dumps.