0% found this document useful (0 votes)
218 views

Lab 3.4 If My Calculations Are Correct

This document describes a lab where students will write custom reporter and predicate blocks in Snap! to perform calculations and computations. The lab has students write blocks to find minimum and maximum values, check if a number is between two others, check word length, calculate distance between points, and check if a word contains a letter. Developing these blocks helps students learn simple and more advanced computations in Snap!.

Uploaded by

Cora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

Lab 3.4 If My Calculations Are Correct

This document describes a lab where students will write custom reporter and predicate blocks in Snap! to perform calculations and computations. The lab has students write blocks to find minimum and maximum values, check if a number is between two others, check word length, calculate distance between points, and check if a word contains a letter. Developing these blocks helps students learn simple and more advanced computations in Snap!.

Uploaded by

Cora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Introduction

 to  Computer  Science  

Lab  3.4  -­‐  If  My  Calculations  Are  Correct...  


In  this  lab,  you  will  write  custom  reporter  blocks  to  perform  a  number  of  useful  calculations  and  
computations.  

Simple  Computations  
1. Write  a  custom  SNAP  reporter  block  called  "min"  that  determines  which  of  two  numbers  is  smaller  and  
reports  that  value.  If  the  two  numbers  are  equal,  report  either  one.  

2. Write  a  custom  SNAP  reporter  block  called  "max"  that  determines  which  of  two  numbers  is  larger  and  
reports  that  value.  If  the  two  numbers  are  equal,  report  either  one.  

3. Write  a  custom  SNAP  predicate  block  called  "between"  that  determines  if  a  number  is  between  two  
other  numbers.  If  the  first  number  is  equal  to  either  of  the  other  two  numbers  or  is  between  them,  the  
block  should  report  "true".  

4. Write  a  custom  SNAP  predicate  called  "at  least  as  long  as"  that  determines  whether  or  not  word  has  at  
least  a  specified  number  of  letters.  

Stepping  Things  Up  


1. Write  a  custom  SNAP  reporter  block  called  "distance  to"  that  computes  and  reports  the  distance  from  
a  sprite's  position  to  another  point.  Use  the  "x  position"  and  "y  position"  blocks  to  determine  the  
sprite's  position.  Remember  that  the  formula  for  the  distance  between  points  (x1, y1)  and  (x2, y2)  
is:  
 

[ 𝑦! − 𝑦! ! + (𝑥! − 𝑥! )!  
 

2. Write  a  custom  SNAP  predicate  block  called  "contains  letter"  that  determines  whether  or  not  a  word  
contains  a  particular  letter.  You  can  consider  upper-­‐case  and  lower-­‐case  letters  to  be  different  for  the  
purposes  of  matching.  

 
This  work  is  licensed  under  a  Creative  Commons  Attribution-­‐
NonCommercial-­‐ShareAlike  4.0  International  License    

You might also like