Logic Errors 2
Word Problem: All students are given five (5) pencils at the beginning of the school year. Write a function called calc-pencils that takes in the number of students in the school and calculates the number of pencils needed for that school.
To solve this word problem, Louis defined the following function, which runs without any errors:
fun calc-pencils(p): p / 5 end
1 Can you see what is wrong with this definition?
To explain their thinking, they filled out the following Design Recipe:
Directions: All students are given five (5) pencils at the beginning of the school year. Write a function called calc-pencils that takes in the number of students in the school and calculates the number of pencils needed for that school.
Every contract has three parts… calc-pencils::Number->Number There are five pencils for every student
Write some examples, then circle and label what changes… examples: __calc-pencils (100)__ is 100 / 5 __calc-pencils (40)__ is 40 / 5 end
Write the definition, giving variable names to all your input values… fun calculate-pencils(p): __p / 5 end |
2 Read each step in the recipe carefully. In which step did their thinking first go wrong? (circle one)
Contract & Purpose |
Examples & Labels |
Definition |
3 What could they have done to find or avoid the mistake in the first place?
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.