Scratch Lab 9

Name: Shreya Raj

Period: 7

Assignment: Lab #9

Lab 8 Overview

This week’s lab was all about lists. The purpose of the lab was to learn how to create and use lists. By using lists, your code can input a lot more values and be more interactive. For this lab we had to do a pair programming problem and one individual lab problem. The pair programming problem required you to make a list which the sprite would then fill with 10 values when the green flag is clicked. Then when the space bar is clicked the list should clear. Also we had to code the problem so that when the down arrow is clicked all of the values in the list would be added to a sum variable. Then we had to pick one of two indiviual lab problems to complete, I decided to pick problem number 1, "Even or Odd". Click HERE to get to the lab instructions.

My Solution Problem Number 1

This problem create a simple "calculator" to determine whether a number inputed in the list is either even or odd. Then to create a list and have the user give values for the list. The code then should loop through the list and say whether each number in teh list is either even or odd. Finally if there are more even numbers than odd numbers then the sprite should change costumes. Now to solve this problem I used 3 different variable, "even", "odd", and "repeat". I also used a block which I named "Even or Odd " with a parameter. I coded it so that when the green flag is clicked the sprite should switch to costume 1 and set both variables "even" and "odd" to zero. Then I used a repeat until answer=no. So if the user kept wanting to add numbers and said yes as their answer then the sprite would ask for another number and add the answer to the list. Then ask to keep going, yes or no. If the user did not want to continue adding numbers then the code would repeat the length of the list and this is where I put my block and set the parameter to item repeat of the list. The block is coded with an if then else statement so if item repeat of list mod 2 = 0 then say that the number is even. Then to change the "even" variable by 1. But if the number is not divisible by 2 = 0 then to say that the number is odd and change the "odd" variable by 1. Then to solve the last part of the problem I just used and if then statement so if the "odd" variable is greater than the "even" variable than to switch the costume.

My Project Link


  1. What is the length of an “empty” list?
      The length of an "empty" list is zero.
  2. Why are lists more powerful than variables?
      Lists are more powerful that variables because lists are able to hold more that one values than variables can.
  3. Can a list contain different data types? For example, could it store both numbers and words?
      Yes Mr. Davis, lists can hold all kinds of data.
  4. Click HERE to return to homepage.