Computer Programming II

CP2 — Python, Notebook-based

📚 Dr. Arif Solmaz
📅 Spring 2026-27
⏱ 14 weeks · 5 hrs/week
📧 arif.solmaz@istun.edu.tr
"I can decompose a problem into small, testable functions"

Course Information

Course Code
CP2
Semester
Spring 2026-27
Credits / Hours
5 hours/week
Format
Google Colab Notebooks (1 per week)
Language
Python 3
Office Hours
Wednesday, 09:00–11:00 AM

Course Description

This course builds on CP1 foundations to teach functional decomposition — the pipeline mindset. Given a complex problem, students learn to break it into 6-8 small, pure, testable functions, wire them into a pipeline (read → clean → process → output), and verify each piece independently. Every week introduces new tools (dicts, CSV, numpy, matplotlib) in service of this one core skill: decomposing problems into small, testable functions.

The course is delivered entirely through Google Colab notebooks. Each week includes one comprehensive notebook with concepts, worked examples, guided practice, and exercises. Students work at their own pace within the weekly deadline.

Learning Outcomes

Upon successful completion of this course, the student will be able to:

  1. Apply the four refactoring moves (Rename, Extract, Simplify, Document) to transform working code into clean, readable code.
  2. Design and implement functions with proper argument patterns, default values, and Google-style docstrings.
  3. Apply the decomposition recipe (Read → Decompose → Name → Contract → Draw → Code) to break complex problems into 6-8 small functions.
  4. Use dictionaries as pipeline tools for counting, histogram generation, and fast lookups.
  5. Read, validate, and write structured data in CSV and JSON formats with schema verification.
  6. Clean and normalize real-world data by handling missing values, outliers, and inconsistent formats.
  7. Use numpy for vectorized computation and matplotlib for clear, labeled visualizations.
  8. Build, test, and organize a complete data-processing pipeline with independent, verifiable stages.

Weekly Schedule

Week Topic Key Content Notebook
Phase 1 · From Code to Clean Code (Week 1)
01
From Working to Clean: The Refactoring Mindset
CP1 review, four refactoring moves, code smell catalogue Open Notebook
Phase 2 · The Decomposition Recipe (Weeks 2-3)
02
Functions with Superpowers
Advanced functions, default/named args, mutable default trap, docstrings Open Notebook
03
The Decomposition Recipe: Divide & Conquer
Modular thinking, dependency graphs, I/O contracts, bottom-up implementation Open Notebook
Phase 3 · Data Tools for Your Pipeline (Weeks 4-5)
04
dict as a Pipeline Tool
Counters, histograms, lookups with dict Open Notebook
05
Reading the World: CSV/JSON as Pipeline Input
CSV/JSON read/write, schema validation Open Notebook
Phase 4 · Processing Stages (Weeks 6-7)
06
Clean Stage: Data Cleaning & Normalization
Missing/outlier values, normalize/standardize Open Notebook
07
Compute Stage: numpy for Efficient Processing
numpy arrays, vectorization Open Notebook
Phase 5 · Output & Verification (Weeks 8-9)
08
Present Stage: matplotlib for Pipeline Output
matplotlib standards: title/label/grid/legend Open Notebook
09
Verify Stage: Testing Your Pipeline
Assert-based testing, expected output per stage Open Notebook
Phase 6 · Scaling Your Pipeline (Weeks 10-11)
10
Measuring Your Pipeline: Performance
Time-based benchmarking, per-function profiling Open Notebook
11
Organizing Your Pipeline: Project Structure
Repo structure, src/, sys.path, imports Open Notebook
Phase 7 · Proving Mastery (Weeks 12-14)
12
Mini Project v2: Sensor Log Analyzer (Start)
Clean + normalize + summary + plot + export Open Notebook
13
Mini Project v2.1: Improve & Extend
CONFIG parameterization, moving average/median filter, expanded tests Open Notebook
14
Final: Demo & Reflection
Project demo, test report, written reflection Open Notebook

Course Delivery & Learning Contract

What Students Can Expect Every Week

  • Protected class time: the 5-hour session starts and finishes according to the official timetable, with a visible agenda and planned breaks.
  • Clear explanation: each major idea follows explain → worked example → prediction → test → interpretation.
  • Questions and voice: questions are welcome throughout; checkpoints reserve explicit time for think-pair-explain, misconceptions, and open questions.
  • Professional purpose: the course is designed for Mechatronics Engineering students and repeatedly connects concepts to reusable software, numerical pipelines, testing, and engineering data analysis.
  • Exam alignment: notebooks label the reasoning moves rehearsed on assessments. Exams use the same verbs and standards with new values or contexts.
  • Materials: weekly notes, runnable examples, core practice, feedback checkpoints, optional extensions, and references are provided from the start of the term.

Assessment & Grading

ComponentWeightDescription
Midterm Exam 50% Written/practical exam covering Weeks 1-7 concepts
Final Exam 50% Comprehensive exam covering all 14 weeks

Assessment consists only of the midterm exam (50%) and final exam (50%). Weekly notebooks, exercises, projects, demonstrations and presentations are ungraded practice; no weekly submission is required.

Practice Feedback Checklist

  • Completeness: Core functionality explored during practice
  • Correctness: Code produces expected output for given inputs
  • Code quality: Readable variable names, proper indentation, comments where appropriate
  • Decomposition: Evidence of functional decomposition — small, testable functions with clear contracts

Course Policies

Attendance

Regular attendance is expected. Students who miss more than 30% of classes may be denied the right to take the final exam, per university regulations.

Academic Honesty

All work must be your own. You may discuss general approaches with classmates, but your code must be written independently. The following are considered violations:

  • Copying code from another student or external source without attribution
  • Sharing your exercise solutions with other students
  • Using work generated entirely by AI tools without understanding and modification

AI Tool Usage

AI assistants (ChatGPT, Copilot, etc.) may be used as learning aids to understand concepts. However, you must be able to explain and modify any code you write. Exercises are designed to build your skills progressively — bypassing them with AI defeats the purpose and will leave you unprepared for exams.

Communication

For course-related questions, email arif.solmaz@istun.edu.tr with your course code (CP2) in the subject line. Office hours: Wednesday, 09:00–11:00 AM.

References & Resources