Michigan Programming for Everybody Python Notes

40 mins

A concise study guide with checked Python 3 examples, 50 flashcards, and a 25-question practice quiz for Michigan’s Python for Everybody course (Chapters 1-5).

Study with the HyNote Study Loop

How it works

Map: Summary

Read the summary for the big picture, then scan the mind map to see how the topics connect.

Programming is writing precise instructions for a very fast, very literal machine: variables store data, expressions compute, conditionals choose, functions package reusable steps, and loops repeat — five chapters, four programming patterns.

Quick answer: this course teaches the four basic patterns every program is built from, using Python 3 as the language. Variables, expressions, and statements store and compute values. Conditional code makes the program choose. Functions package steps for reuse. Loops and iteration repeat work until the problem is solved. The CPU executes instructions; Python's interpreter parses source and can execute statements interactively. In this course you do not run a separate compilation command, although CPython compiles source internally to bytecode.

Variables follow one rule — evaluate the right side first, then store into the left. Expressions follow precedence: parentheses, exponentiation, then * / // %, then + -. Exponentiation is asymmetric with unary signs: -22 is -4, but 2-2 is 0.25. / gives a float; // floors the quotient. input() always hands you a string, so convert before math — the pay calculator (float(hrs) * float(rate)) is the course's first real program. Bad input is handled with try/except, not hope.

Conditionals split the program's path: if, elif, and else with colon-and-indent blocks; comparisons produce True or False; and, or, not combine them. Functions wrap steps behind a name: def with parameters, return to hand a value back — and a function without return gives None, the classic printed-output surprise. Loops repeat: while for indefinite repetition, for over any iterable for definite repetition, break to exit, continue to begin the next iteration. A while loop needs a path to a false condition or break.

The loop idioms are the course's final gift: count with count = count + 1, sum with total = total + value, find extremes with the largest-so-far pattern — and use the None sentinel instead of -1 when the values might all be negative. Master these five chapters and the rest of Python for Everybody is built on top of them.

Key points

  • The CPU executes; RAM is fast and temporary; disk is slow and permanent
  • The interpreter parses source and supports immediate interactive execution
  • Right side first, then store: x = x + 2
  • Precedence: parentheses, **, * / // %, then + -
  • / gives a float; // floors the quotient; % gives the matching modulo
  • input() returns a string — always convert before math
  • int(1.9) truncates to 1
  • = assigns; == compares
  • try/except survives bad input
  • def + parameters + return; no return means None
  • while is indefinite; for is definite; break exits; continue skips
  • Idioms: count, total, largest-so-far, None sentinel, filtering

Common traps

  • Doing math on input() without converting — crash or concatenation
  • Writing = when you meant == (or the reverse)
  • Believing int() rounds — it truncates
  • Mixing up // (quotient) and % (remainder)
  • Forgetting the colon or the indent — the indent is the block
  • Expecting a print-only function to return something — it returns None
  • Giving a while loop no path to a false condition or break — infinite loop
  • Starting largest at -1 when negatives are possible — use the None sentinel
  • Using a reserved word as a variable name

More from this Note's tags