Progress: 59% ββββββββββββββββββββ 59%
Primary goals: β¬ Pass PCEP β¬ Pass PCAP β¬ Build a practical Python portfolio β¬ Be ready for Python development opportunities
β Python available on Linux β Thonny installed and opened β PyCharm installed and opened β VS Code installed and opened β Run and save Python programs β Comments β Keywords and identifiers β Variables β Basic data types
β Creating strings β Indexing and negative indexing β Slicing β String methods β Formatting with f-strings
β Lists β Tuples β Sets β Dictionaries
β Arithmetic operators β Assignment operators β Comparison operators β Logical operators β Bitwise and special operators β Implicit type conversion β Explicit type casting
β if β if / else β if / elif / else β Nested conditions
β for β range() β while β break β continue β pass β Loop else blocks
β Creating and calling functions β Parameters and positional arguments β Return values β Default parameters β Keyword arguments β *args β Recursion β Lambda functions
β Local scope β Global scope β Enclosing and nonlocal scope β Built-in scope β global and nonlocal keywords
β import β from ... import β Module aliases β Creating modules β Packages
β Reading files β Writing files β with open() β File modes β Working with directories
β try β except β else β finally β¬ Common built-in exceptions β¬ Custom exceptions
β¬ Classes β¬ Objects β¬ Attributes β¬ Methods β¬ Constructors and init β¬ self β¬ Inheritance β¬ Method overriding β¬ super() β¬ Encapsulation β¬ Polymorphism
β¬ Multiple inheritance β¬ Multilevel inheritance β¬ Method Resolution Order β¬ Operator overloading β¬ Iterators β¬ Custom iterators
β¬ Calculator β¬ File organiser β¬ CSV reader β¬ API client β¬ AI API script β¬ Property cashflow calculator β¬ Linux automation script β¬ GitHub portfolio
β¬ PCEP exam β¬ PCAP course β¬ PCAP exam
These are deliberate additions for practical development ability and employability. They are not listed as part of the supplied training presentation.
β¬ Git basics β¬ Virtual environments (venv) β¬ pip and dependency installation β¬ requests for APIs β¬ pathlib for files and paths β¬ JSON handling β¬ argparse for command-line tools β¬ pytest for testing β¬ Build five polished portfolio projects
This document is the working hub for the PCEP and later PCAP training. It condenses the supplied Python for Beginners presentation into practical study notes without copying the full slide deck or its animations.
Presentation: Python for Beginners, presented by Isaac. Primary environment: Thonny IDE. Python scripts use the .py extension. Other IDEs such as IDLE, PyCharm and VS Code can also run Python.
Python is cross-platform, free and open-source. The language is case-sensitive and uses indentation to define code blocks.
Keywords are reserved words with a special meaning and cannot be used as variable, function or class names. Identifiers are names given to variables, functions, classes and methods.
Identifier rules:
- Start with a letter or underscore.
- May contain letters, digits and underscores.
- Cannot start with a digit.
- Cannot contain spaces or special symbols.
- Cannot be a Python keyword.
- Names are case-sensitive.
A hash symbol starts a single-line comment. Triple-quoted text can span multiple lines, although it is also used for strings and docstrings.
- int: whole numbers
- float: decimal numbers
- complex: numbers with real and imaginary parts
- type() reports the class of a value
Python also supports binary, octal and hexadecimal notation.
- list: ordered, indexed, mutable, duplicates allowed
- tuple: ordered, indexed, immutable
- set: unordered collection of unique values
- dictionary: ordered key-value pairs with unique immutable keys
Strings are immutable sequences of characters enclosed in single or double quotes. They support indexing, negative indexing, slicing, concatenation, iteration, membership tests and methods such as upper(), lower(), replace(), split() and startswith(). f-strings embed values inside text.
Implicit conversion happens automatically where Python can safely promote a value, such as int to float. Explicit conversion uses functions such as int(), float(), str() and complex(). Explicit conversion may discard information, for example converting a float to an integer.
- print() displays output.
- input() reads user input and returns a string.
- Convert input explicitly when a number is required.
- Arithmetic: +, -, *, /, //, %, **
- Assignment: = and compound forms such as +=
- Comparison: ==, !=, <, <=, >, >=
- Logical: and, or, not
- Bitwise operators
- Special operators such as membership and identity operators
A namespace maps names to objects. Python commonly uses built-in, global, enclosing and local scopes. A name referenced inside a function is searched from the closest local scope outward. Variables declared outside functions are global. Variables created inside functions are local unless global or nonlocal is used.
- if executes a block when a condition is true.
- if...else chooses between two alternatives.
- if...elif...else handles multiple alternatives.
- Nested if statements place one condition inside another.
- for iterates through a sequence or range.
- while repeats while a condition remains true.
- break exits a loop immediately.
- continue skips to the next iteration.
- pass is a valid placeholder that performs no operation.
- Loop else blocks run when a loop finishes normally, but not after break.
A function is a reusable block of code declared with def. It may accept parameters and return a value.
Function concepts:
- positional arguments
- keyword arguments
- default parameter values
- arbitrary positional arguments using *args
- return ends a function and sends a value back
- recursion is when a function calls itself and requires a base condition
- lambda creates a small anonymous function containing one expression
A module is a Python file containing code that can be imported. Use import module and access members with dot notation. Use from module import name to import specific definitions. Aliases can shorten names. Importing everything with * is discouraged because it can create naming collisions.
A package groups related modules in directories. The presentation describes init.py as the marker used for a package.
File workflow:
- Open the file.
- Read or write.
- Close it.
Prefer with open(...) because it closes the file automatically, including when an exception occurs. Common modes include r for reading and w for writing. Opening an existing file with w erases its current contents.
The os module provides directory functions such as getcwd() and chdir().
Exceptions are runtime problems represented by exception objects.
Use:
- try for code that may fail
- except to handle a specific exception
- else for code that runs when try succeeds
- finally for cleanup that must always run
Examples include ZeroDivisionError, FileNotFoundError, ImportError and IndexError. Custom exceptions can inherit from Exception.
A class is a blueprint; an object is an instance of that class.
Key concepts:
- attributes store object data
- methods are functions defined inside classes
- init initializes new objects
- self refers to the current instance
- inheritance creates a child class from a parent class
- method overriding replaces inherited behavior
- super() accesses parent-class behavior
- encapsulation groups data and methods and uses naming conventions such as _ and __
- polymorphism allows the same interface or method name to behave differently
- multiple and multilevel inheritance are supported
- Method Resolution Order decides which inherited method Python selects
- operator overloading uses special methods such as add and lt
An iterator returns items one at a time. It implements iter() and next(). iter() creates an iterator and next() retrieves the next value. When exhausted, it raises StopIteration. A for loop handles this process automatically.
Master first:
- variables and basic data types
- strings and type conversion
- lists and tuples
- dictionaries and sets
- input and output
- operators
- if, elif and else
- for and while loops
- functions, parameters and return values
- basic exceptions, modules and scope
Treat detailed OOP, inheritance, operator overloading, custom iterators and advanced package structure as later or PCAP-oriented material unless the instructor includes them in the PCEP assessment.
For each class topic:
- Add concise notes here.
- Type every example manually in Thonny.
- Recreate the same exercise in PyCharm to build IDE familiarity.
- Save useful scripts in a structured Git repository.
- Add mistakes, corrections and exam traps to this document.
Official references:
- GeeksforGeeks: https://www.geeksforgeeks.org/
- Python Institute: https://pythoninstitute.org/
Practice resources:
- Simulations: https://codepen.io/collection/ExkyKG
- Mock Exam: https://docs.google.com/forms/d/e/1FAIpQLSdhv6phnlHopuLGqpoJdkFoLR_lrgOsINWyIjz2UD4b7LsLFQ/viewform
Mock exam notes:
- Keep this as a study resource only.