OIM3640 - Problem Solving and Software Design

2026 Spring

Session 04 (1/29)

contain

Today's Agenda

Announcements

  • What you should have done:
    • Submitted your oim3640 GitHub repo URL on Canvas
    • Read the syllabus
    • Installed all required software
  • Communications:
    • Email - specify course # in subject title, e.g., "OIM3640: GitHub settings"
    • Meet with me in person at least once this semester
  • Questions?

🙋 Quick Questions

  • What is version control and why do we use GitHub?
  • What does "commit" mean in Git?
  • What does "push" do?
  • What is one big difference between a programming language and English?

Terminal Basics

You can also use the terminal (command line) for file navigation:

Command What it does
cd folder Change directory (go into a folder)
cd .. Go up one level
ls (Mac) / dir (Win) List files in current folder
mkdir folder Make a new folder
pwd Print working directory (where am I?)

Fix: Conda Warning in VS Code (Windows)

  • If you see red text like conda activate base before your output:
  • Your code is still correct! But to fix the warning:
    • Option 1 (Recommended): Run this once in Anaconda Prompt:
      conda init powershell
      
      Then restart VS Code.
    • Option 2 (Quick workaround): In VS Code Settings:
      Terminal → Default Profile → Windows → Select Command Prompt

Repository Structure

oim3640/                     # Main course repository (public)
├── notebooks/               # Jupyter notebooks (from Think Python 3)
├── code/                    # Python scripts and modules
├── data/                    # Data files
├── logs/                    # Learning logs (Markdown files: s01.md, s02.md, ...)
├── mini_projects/           # Mini projects (may be here or separate repos)
└── README.md                # Portfolio homepage

Lectures

Chapter 1: Programming as a Way of Thinking

Key ideas (not syntax!):

  • Programming = problem solving: Breaking problems into smaller steps
  • Python as a tool: Interpreter executes your instructions
  • Errors are normal: SyntaxError, NameError, TypeError are your friends
  • Experiment and iterate: Try things, see what happens, learn

Read the error messages — they tell you what went wrong!

Chapter 02 - Variables and Statements

Main concepts:

  1. Values and Types — What kinds of data exist?
  2. Variables — How do we store and name things?
  3. Expressions — How do we compute?
  4. Statements — How do we give instructions?

Values and Types

Every piece of data in Python has a type:

Type Example What it is
int 42 Whole numbers
float 3.14 Decimal numbers
str "hello" Text (strings)
bool True, False Logical values

Use type(x) to check what type something is.

Variables: Naming Things

A variable is a name that refers to a value:

message = "Hello, World!"
n = 42
pi = 3.14159

Good naming matters! Which is better?

# Option A
x = 26.2

# Option B
marathon_miles = 26.2

Variable Naming Rules & Style

Rules (will cause errors if broken):

  • Must start with a letter or underscore
  • Can contain letters, numbers, underscores
  • Case-sensitive (Namename)
  • Cannot use Python keywords (if, for, while, etc.)

Style (follow for readability):

  • Use lowercase_with_underscores (snake_case)
  • Be descriptive: student_count not sc
  • Avoid single letters except for counters (i, j)

Expressions and Operators

An expression is code that produces a value:

Operator Meaning Example
+, -, * Add, subtract, multiply 3 + 47
/ Division (float result) 7 / 23.5
// Integer division 7 // 23
% Modulo (remainder) 7 % 21
** Exponent (power) 2 ** 38

Understanding Modulo %

The modulo operator gives the remainder after division:

17 % 5   # → 2  (17 = 5×3 + 2)
10 % 2   # → 0  (10 is even, no remainder)
7 % 10   # → 7  (7 < 10, so remainder is 7)

Common uses:

  • Check if a number is even: n % 2 == 0
  • Get last digit: n % 10
  • Wrap around (clock math): (hour + 5) % 12

Statements vs Expressions

  • Expression: Produces a value → 2 + 3, len("hello")
  • Statement: Does something → x = 5, print("Hi")
# This is a statement (assignment)
total = 100 + 50

# This is an expression (used in a statement)
print(total * 0.08)

Comments: Writing for Humans

# Calculate the tip (15% of total)
tip = total * 0.15

When to comment:

  • Explain why, not what (code shows what)
  • Complex logic or non-obvious decisions
  • TODO notes for yourself

📝 Your Turn

Open Chapter 1 & 2 notebooks (chap01.ipynb, chap02.ipynb)

Work through the examples and exercises.

Questions? Ask now!

Before You Leave (5 min)

  • Any questions so far?
  • Start your Learning Log for today (logs/s04.md)
  • Work on exercises (okay to continue later)
  • Note down questions for next time
  • Push your work to GitHub

Next session: Functions (Chapter 3)

global styles