Lab #9 Write Up

Name: Kelly Yokoi

Period: 7

Assignment: Lab #9

Lab Overview

Scratch Lab#9 is all about lists. A list stores a group of values and is really handy since it stores multiple pieces of information at once. It is like a variable containing multiple variables.

My Solution Problem #1

The first problem had us program a "calculator" that would determine if a number is even or odd. I made a block called "Calculate Even or Odd" and put an if than else statement in. I had 2 operator blocks: one mod and one = block. Even numbers are divisable by 2 so I put "Answer mod 2=0" so if the remainder is 0 then the program would know that the number is even. If that wasn't the case then the program would say the number is odd. To allow the user to input numbers I created a list called numbers and a variable called continue. When the green flag is clicked continue would be set to "yes" and a program would repeat until "continue=no". Inside the repeat block the sprite would ask for a number, that number would be added to the list and the sprite would tell the user if the number is even or odd. After that the sprite would ask if the user would like to continue with the list. If the user says "no" the program would stop. I also needed the calculator to record how many even and odd numbers the user inputed. So In the "Calculate Even or Odd" block I made 2 variables, "#of even" "# of odd", and put the "change # of even by 1" after the sprite says "This number is even!" and the odd one after the sprite determines it's odd. I also made another condition where if the "# of even" was greater than "#of odd" then the sprite would change costume. Otherwise it would be the original sprite. I made this using operator, look, and control blocks.

Problem #1

Questions

  1. Question #1-

  2. What is the length of an "empty list?

  3. Question #2

  4. Why are lists more powerful than variables?

  5. Question #3

  6. Can a list contain different data types? For example, could it store both numbers and words?

Click HERE to return to homepage.