Word Problem: Write a function that returns the area of a circle given its diameter.

To solve this word problem, Sai defined the following function, which runs without any errors:

fun circle-area​(​diameter​): num-sqr​(​diameter​) * num-pi end

1 Can you see what is wrong with this definition?

To explain their thinking, they filled out the following Design Recipe:

Directions: Write a function that returns the area of a circle given its diameter.

Contract and Purpose Statement

Every contract has three parts…​

circle-area::Number->Number

Given the diameter, multiply pi by radius squared to get the area

Examples

Write some examples, then circle and label what changes…​

examples:

circle-area (10) is num-sqr​(​10 / 2​) * num-pi

circle-area (50) is num-sqr​(​50 / 2​) * num-pi

end

Definition

Write the definition, giving variable names to all your input values…​

fun area(diameter):

num-sqr​(​diameter​) * num-pi

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). CCbadge 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.