Hour of Math
Catalogue
Data Science and Programming

Basics of Python Programming I

Write, debug and reason about Python programs using variables, selection and iteration.

  1. Meet PythonYou’ll run seven real Python programs β€” including turtle drawings and the flag of Nigeria β€” and learn what Python, a program and syntax are.
  2. First Run & print()By the end you can run a program, explain why some lines show nothing, and write print() statements that produce an exact required output.
  3. Values & the Five TypesBy the end you can name the type of any written value on sight, state the giveaway that decided it, write a value of each type, and explain why "5" + "3" is 53 rather than 8.
  4. Variables β€” Naming a ValueBy the end you can create variables with =, use one value in several places, fix a name Python will not accept, and turn a short algorithm written in words into a working program.
  5. Not Algebra: x = x + 1By the end you can trace a variable that is updated several times, say why x = x + 1 is not a contradiction, spot an update that silently does nothing, and write a running total of your own.
  6. input(): Data From the UserBy the end you can write the ask-and-listen pair, trace a program that pauses, fix one that throws its answer away, and write a program that greets whoever runs it.
  7. Arithmetic Operators & Order of OperationsBy the end you can name the parts of an expression, say what type each operator hands back, and work out any line of arithmetic in the order Python actually does it.
  8. Floor Division, Remainder and PowersBy the end you can split any total into whole units and a leftover, say what each of the three operators hands back, and place them all correctly on the priority ladder.
  9. How Python EvaluatesBy the end you can write out how Python works any line down to a single value, tell an expression from a statement, and explain why a line can do real work and leave no trace.
  10. Checkpoint 1 β€” Auntie Ngozi's Snack StandBy the end you can combine variables, input, conversion and every operator so far inside fresh, immersive programs β€” and prove it without a hint.
  11. Build: Area of a CircleBy the end you can write a complete program from an empty file that imports a module, converts input, calculates a result, and reads clearly to someone else.
  12. Tracing I: Read-After-Write, = vs ==By the end you can trace a short sequential program by hand, tell = apart from == on sight, and fix a program that silently fails because of that exact mix-up.
  13. Tracing II: Multi-Variable Trace TablesBy the end you can build a multi-variable trace table by hand, read a blank cell correctly, and use tracing to catch a bug a program never announces.
  14. Errors I: SyntaxError, NameError, TypeErrorBy the end you can read Python's own error messages, name which of three error types you're facing, and fix each one on sight.
  15. Errors II: A Debugging Process + Peer ReviewBy the end you can find and explain a logical error with no error message to guide you, and follow one process for every kind of bug in this unit.
  16. Comparison & Boolean OperatorsBy the end you can use all six comparison operators, combine them with and/or/not, and know why comparing mismatched types never crashes.
  17. Checkpoint 2 β€” Sports Day at Unity HighBy the end you can trace, debug and compare inside fresh, real programs β€” and prove it without a hint.
  18. Nesting, Precedence & the Non-Distributive TrapBy the end you can predict exactly how Python groups a chain of comparisons and and/or, and use brackets to force the grouping you actually mean.
  19. Selection I β€” if and if-elseBy the end you can write programs that make their own decisions, and you know the two marks, a colon and an indent, that tell Python what belongs to a choice.
  20. Selection II β€” elif, nested if, and the positive/negative/zero buildBy the end you can choose between three or more outcomes, explain why the order of the tests matters, and build the positive, negative or zero program from a plan in words.