Referenced from lesson Data Displays and Lookups

Consider the table below, and the four value definitions that follow:

shapes-table

name corners is-round

"triangle"

3

false

"square"

4

false

"rectangle"

4

false

"circle"

0

true

shapeA = shapes-table.row-n(0)
shapeB = shapes-table.row-n(1)
shapeC = shapes-table.row-n(2)
shapeD = shapes-table.row-n(3)

1) Match each Pyret expression (left) to the description of what it evaluates to (right).

shapeD

1

A

Evaluates to 4

shapeA

2

B

Evaluates to the last row in the table

shapeB["corners"]

3

C

Evaluates to "square"

shapeC["is-round"]

4

D

Evaluates to true

shapeB["name"]

5

E

Evaluates to false

shapeA["corners"]

6

F

Evaluates to 3

shapeD["name"] == "circle"

7

G

Evaluates to the first row in the table

2) Fill in the blanks (left) with the Pyret lookup code that will produce the value (right).

a.

"rectangle"

b.

"square"

c.

4

d.

0

e.

true

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap:Integrated Oklahoma by Jen Poole is licensed under a Creative Commons 4.0 Unported License. Based on a work at www.BootstrapWorld.org. Permissions beyond the scope of this license may be available by contacting schanzer@BootstrapWorld.org.