Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CSP U5L06 Loops Investigate Activity Guide

Warm-Up​ - Imagine you are interested in finding out how much time it takes on average to walk
from one end of your school to the next. You've decided to figure this out on your lunch break, and
are able to complete the walk 20 times. What would your algorithm look like? Where could a loop
show up?

Note: ​ You do not need to write your algorithm in a programming language. You can write it out in
English or in pseudocode. Also, do not spend too much time on this part (under 5 minutes).

____________________________________________________________
Level 2 - Run the app on Level 2 of Code Studio then answer the following questions
1. What information does the user input?
How many times the coin flips.

2. How does the app process that information?


By inserting the text of how many times the coin flips.

a. What is being repeated? Where is there an opportunity to use a loop?


The number of flips.
3. What information does the app output?
The type of coin.
____________________________________________________________
Level 3 - Run the program on Level 3, with code this time then answer the following
questions
1. Run this program for 10 coins flips, 100 coins flips, 1000 coin flips, and 10,000 coin flips.
When do you notice it taking longer? ​When you do 10,000 flips.

2. On what lines of code is the program using a loop?


4,7,12

3. Which lines of code decide how many times to flip the coin?
7,10,6,4
4. What does the ​++​ command seem to do
For example: ​tails++​.

____________________________________________________________
Level 4 - Run the program on Level 4, paying attention to the code

1. Find four different for loops in the program. What do they each do?
7,12,18,23,28 they make sure the text shows up in all the boxes.

2. Take a look at the names of the screen elements in Design Mode. Then navigate back to
the code. How is ​"text" + i​ used? How does it evaluate with each round of the loop?
The text+i input means the function is repeating the text i loop function.

3. What happens if you change the text box variable names? Try changing them from ​text0​,
text1​, etc. to ​textbox0​, ​textbox1​, etc. What do you need to change in the code for the
program to still work? ​Not going to work, not labeled properly.

4. What happens if you change the Boolean expression ​i < 5​ in the for loops? Change all the
Boolean expressions to each of these options and explain what happens:
a. i < 4
b. i < 3
c. i <= 4
5. Change it to text box

You might also like