Learning Rooms/△ Level 2 · Builder/Electronics
Software Engineering: Crash Course Computer Science #16
CrashCourse · Length: see YouTube · captions on YouTube · nothing loads until you press play
By the end you can…
- Split a data-processing program into small functions that each do one job.
- Chain functions so the output of one is the input of the next.
- Test each function on its own before testing the whole program.
Watch it all: no segment has been checked by hand for this video yet.
1.Predict before you press play
to_celsius(to_volts(232)): which function runs first?
Pick one before you press play. A wrong guess is fine: it is what makes the video stick.
2.See the idea first
Play with this diagram for a minute (borrowed from the lesson “Package a calculation as a function”, on the same idea). It gives you something to hang the video on.
Loading the interactive…
Can't use the diagram? Read a description instead
The function machine shows a Python function with a docstring, three versions of its body and a set of assert tests. For wheel_speed_m_per_s: version A (rpm / 60 * math.pi * diameter_m) passes all three tests; version B forgets to divide by 60 (60 rpm, 0.1 m gives 18.85 instead of 0.314 m/s); version C uses 2π with the diameter (0.628 m/s).
3.Watch, actively
How big programs are broken into functions and modules, tested and built by teams.
Length: see YouTube · captions on YouTube · source
Nothing loads from YouTube until you press play.
Watch for…
- → Watch how big programs are broken into functions and modules that different people can build and test separately.
Pause whenever you like. Rewatching a hard minute is a good habit, not a failure.
Can't stream it? Read the idea instead
Large programs are built by splitting them into functions and modules that each do one job behind a clear interface. Teams can then work on parts separately, test each part on its own and change the inside of one part without breaking the others.
What the video covers (our own note, written when we verified it): How big programs are broken into functions and modules, tested and built by teams.
Written by Tactiverge in our own words, not a transcript. The full lesson below explains the idea without the video.
Read it instead
- Lesson: Decompose a program into functions · The full lesson explains the idea in text, worked examples and diagrams, with no video needed.
- Engineering Atlas: Functions and decomposition · Writing a robot's wheel-speed conversion once as a function means a single fix reaches every part of the code that uses it.
- Field Guide: Functions and return values · A short reference entry on the same idea.
Jot down one thing that surprised you and one question you still have.
4.Practise what you just saw
These come from the lesson that use this video and are checked on the server. Wrong answers get a hint and another try.
Practice 1
Why test to_volts and to_celsius separately before the whole pipeline?
Practice 2
With volts = raw × 3.3 / 1023, how many millivolts is one ADC count, to 2 decimal places?
Practice 3 · a fresh version every time
A 10-bit ADC reads raw = 307. to_volts(raw) returns raw * 3.3 / 1023, and to_celsius(v) returns (v - 0.5) * 100 (a TMP36-style sensor: 10 mV per °C with a 0.5 V offset). What is to_celsius(to_volts(307)), in °C?
Practice 4
Which function does one job?
6.Where engineers use it
Embedded and data teams structure sensor code exactly like this, often in separate files, so a calibration change touches one small, tested function.
From the applied view in the lesson Decompose a program into functions. Checked by automated tests only.
7.Build something with it
Follow-up project
Add plausible(temp_c) (True from −40 to 125 °C) and count_over(values, limit_c) to the pipeline, each with a docstring and two asserts. Then rewrite your main program so it reads like a short list of steps.
Where this video lives
- Decompose a program into functions · Level 2, week 7
In the course catalogue: CSE-210 Python for engineers
The video is by CrashCourse, embedded from YouTube with privacy-enhanced mode and never autoplayed. The room around it (prompts, notes, practice, projects) is Tactiverge's, written with AI assistance and checked by automated tests only.