Lite / Building Machines That Respond / Week 3
Week 3: Variables and data types
This week you will
- Store values in well-named variables with units and update them as counters and running totals.
- Distinguish int, float, str, bool and list, and predict the type of an expression.
- Explain why 0.1 + 0.2 is not exactly 0.3 and compare floats with a tolerance.
Lessons
- Variables that track a changing machine · about 30 min
A robot adds speed × time to its distance fifty times a second. How does one variable keep track of all that? - int, float, str and list · about 35 min
A sensor file says "23.5". Add 0.4 and Python refuses. Why is a number in quotes not a number? - Why 0.1 + 0.2 is not 0.3 · about 35 min
Ask Python whether 0.1 + 0.2 == 0.3 and it says False. Is your computer broken?