Course Overview

This course introduces 2nd-year bachelor students to the fundamentals of programming using Python, one of the most widely used and accessible programming languages in the world. Designed for beginners with no prior programming experience, the course progressively builds practical skills in algorithmic thinking, data manipulation, and problem-solving.

Python is a high-level, general-purpose, interpreted language known for its readable syntax and versatility. It is used across engineering, data science, artificial intelligence, automation, and web development. This course equips students with the foundational knowledge and hands-on experience necessary to write, test, and debug elementary Python programs and apply programming concepts to practical engineering problems.


Learning Objectives

Upon completing this course, students will be able to:

  1. Acquire practical programming foundations using Python, including installation, environment setup, and both interactive and script modes of execution.

  2. Develop algorithmic logic to solve simple problems through variables, data types, operators, and expressions.

  3. Master fundamental data structures, including lists, tuples, and dictionaries, and understand when to use each.

  4. Write, test, and debug elementary Python programs using conditional structures, loops, and functions.

  5. Apply programming concepts to practical engineering cases, including file manipulation and data analysis.

  6. Organize code modularly using functions, modules, and packages.

  7. Model real-world objects using classes and object-oriented programming principles.

  8. Persist data by reading from and writing to files, including JSON and pickle formats.


Prerequisites

  • No prior programming experience required

  • Basic mathematics knowledge (high school level)

  • Ability to use a computer (file navigation, text editor usage)


Course Content

Chapter 1: Installing and Using Python

  • Installing Python 3 on Windows using the official installer

  • Understanding the Python development environment: interpreter, source files, code editors, and IDEs

  • Using the interactive interpreter (REPL) for experimentation

  • Distinguishing between interactive mode and script mode

  • Creating, saving, and executing Python scripts (.py files)

  • Installing and configuring Visual Studio Code with the Python extension

  • Introduction to virtual environments

  • Common errors (SyntaxError, NameError, TypeError) and a seven-step debugging procedure

Chapter 2: Basic Notions

  • Python as a calculator: arithmetic operators (+, -, *, /, //, %, **)

  • Operator precedence (PEMDAS) and numeric literals (underscores, scientific notation)

  • Variables: creation, modification, naming rules, and PEP 8 conventions

  • Multiple, chained, and compound assignment operators

  • Core data types: int, float, bool, str, None

  • Type conversion (casting) and the ValueError exception

  • Built-in functions (abs, min, max, pow, round) and the math module

  • Import styles: import module, from module import function, aliasing

  • Producing output with print() and string formatting (str.format(), f-strings)

  • Reading user input with input() and safe type conversion

  • Writing readable code: comments and docstrings

  • Common errors: TypeError from mixing types, ValueError from invalid conversions, floating-point precision surprises

Chapter 3: Conditional Structures

  • Python's block structure and indentation (PEP 8 convention)

  • The minimal if statement

  • The if-else alternative form

  • The complete if-elif-else structure

  • Nested if statements

  • Why elif matters: avoiding consecutive independent if statements

  • Comparison operators: ==, !=, >, <, >=, <=

  • Chained comparisons (e.g., 0 <= x <= 100)

  • Equality (==) versus identity (is)

  • Predicates and booleans: Truthy and Falsy values

  • Logical operators: and, or, not, their truth tables and precedence

  • Conditional expressions (ternary operator)

  • Common errors: IndentationError, SyntaxError from missing colon or misused =, TypeError from comparing incompatible types

Chapter 4: Loops

  • The idea of repetition: why loops exist

  • Two kinds of loops: condition-controlled (while) and collection-controlled (for)

  • The while loop: syntax, flow, and the counter pattern (initialize, test, update)

  • Infinite loops: causes and diagnosis (Ctrl+C, tracing)

  • while loops with user input and sentinel values

  • The for loop as a "for-each" loop

  • The range() function: one-, two-, and three-argument forms

  • Counting loops: forward, by steps, and backward

  • Accumulator patterns: counters, sums, products, minimum/maximum, running averages

  • Nested loops: syntax, execution order, and execution counts

  • Controlling loop execution: break and continue

  • The loop else clause (going further)

  • Writing readable loops

  • Common errors: infinite loops, off-by-one errors, uninitialized accumulators, misplaced updates, break/continue outside loops

Chapter 5: Functions

  • What is a function? Benefits: reusability, modularity, readability, maintainability

  • Defining functions with the def keyword

  • Function parameters and arguments

  • Positional versus keyword arguments

  • Return values and the return statement

  • Functions without return (implicit None)

  • Returning multiple values (tuples)

  • Early return and guard clauses

  • Default parameter values

  • Variable-length arguments: *args and **kwargs

  • Variable scope: local vs. global, the LEGB rule

  • The global keyword (brief mention)

  • Docstrings and documentation with help()

  • Modules: creating and importing custom .py files

  • Import styles and the name == "main" guard

  • Packages: organizing modules with init.py

  • Lambda functions: anonymous, single-expression functions

  • Common errors: TypeError from missing/extra arguments, NameError, SyntaxError, IndentationError

Chapter 6: Lists and Tuples

  • Creating and editing lists

  • Definition and creation of lists

  • Inserting objects: append(), insert()

  • Concatenating lists

  • Removing elements: del keyword, remove() method

  • Traversing lists

  • The enumerate() function

  • Creating tuples and understanding immutability

  • When to use lists versus tuples

Chapter 7: Dictionaries

  • What is a mapping? Key-value pairs

  • The two constraints on keys: uniqueness and hashability

  • Creating dictionaries: literals, dict() constructor, zip(), comprehensions

  • Accessing values: [] versus get()

  • Adding, updating, merging entries: assignment, update(), |, |=

  • Deleting entries: del, pop(), popitem(), clear()

  • Testing for key presence with in

  • The three traversals: keys(), values(), items()

  • Views are dynamic

  • Ordering output: sorting by key or value with sorted() and lambda

  • Building dictionaries from data: counting and grouping patterns

  • Inverting a dictionary

  • Dictionary comprehensions

  • Nested structures: dictionary of dictionaries, list of dictionaries, dictionary of lists

  • Dictionaries and functions: passing, returning, **kwargs, call-site unpacking

  • The mutable default argument trap

  • Choosing between a list and a dictionary: lookup cost as the deciding argument

  • Tuples as composite keys

  • Common errors: KeyError, TypeError from unhashable keys, AttributeError, RuntimeError from changing size during iteration, silent overwrite

Chapter 8: Objects and Classes

  • Why classes? Limits of the dictionary representation

  • The class as a blueprint; the object as an instance

  • Defining classes with the class keyword

  • The init() method: the initializer

  • The self parameter: role and convention

  • Creating objects (instances)

  • Instance attributes versus class attributes

  • The mutable class attribute trap

  • Methods: instance methods, class methods (@classmethod), static methods (@staticmethod)

  • Encapsulation: underscore conventions and name mangling

  • Properties: the @property decorator, getters, setters, read-only properties

  • Inheritance: parent and child classes, "is-a" relationship

  • The super() function

  • Method overriding

  • Testing inheritance: isinstance() and issubclass()

  • Polymorphism: one interface, many forms

  • Duck typing

  • Special methods: str(), repr(), eq(), len(), add()

  • Common errors: AttributeError, missing self, TypeError from init() returning a value, mutable class attribute

Chapter 9: Files

  • Why files? Volatile memory versus persistent storage

  • File paths: absolute and relative

  • The pathlib module for portable path manipulation

  • Opening files with open(): file modes ("r", "w", "a", "x", "b", "t")

  • Closing files: the with statement (context manager)

  • Reading files: read(), readline(), readlines(), and for line in f:

  • Stripping the newline character

  • Writing to files: write() and print(file=f)

  • Appending to files

  • Handling file errors: FileNotFoundError, PermissionError, IsADirectoryError

  • try/except for graceful error handling

  • Saving structured data: JSON (json.dump(), json.load(), json.dumps(), json.loads())

  • JSON-compatible types

  • Saving Python objects: pickle (pickle.dump(), pickle.load())

  • Security warning: never unpickle untrusted data

  • Choosing between JSON and pickle

  • Reading CSV files

  • Common errors and the debugging procedure


Teaching Methodology

The course combines theoretical lectures (1h30 per week) with practical lab sessions (1h30 per week). Lectures introduce concepts with clear explanations, examples, and guided demonstrations. Lab sessions provide hands-on experience where students write, test, and debug programs, progressing from simple exercises to engineering-flavored applications.

Each chapter follows a consistent structure:

  • Introduction and learning objectives

  • Concept presentation with examples

  • Guided, engineering-flavored examples

  • Common errors and debugging strategies

  • Practical activity / laboratory preparation

  • Exercises graded by difficulty (Basic, Application, Understanding)

  • Chapter summary and recommended resources


Practical Work Sessions

 
 
Lab Topic  
Lab 1 Getting started with Python environment (installation, interpreter, first script)  
Lab 2 Variables, data types, and operations  
Lab 3 Conditional and repetitive structures (if, elif, else, for, while)  
Lab 4 Functions and modularity  
Lab 5 Data structures (lists, tuples, dictionaries)  
Lab 6 File manipulation and final project  

Final Project Options:

  • Command-line task manager

  • Hangman game

  • Data analysis from a CSV file

  • Interactive quiz with score saving


Assessment

  • Continuous Assessment: 40%

  • Final Examination: 60%

The continuous assessment includes lab participation, submitted exercises, and potentially a midterm project. The final examination tests theoretical understanding and practical programming skills.