1 CS110 - Introduction to Computers and Applications Spring 2016 - Scratch Project #5 Due Date: Friday, April 15th , at 11:00 P.M. Accept Until Date: Friday, April 22 nd , 11:00 P.M. Evaluation: 20 points Submit to Sakai: Scratch program (.sb file) Related Materials: Resources posted in Sakai → Lecture Topics → Scratch Scratch Website: http://scratch.mit.edu/ TA Lab Support Schedule (in Sakai Resources Folder) Questions? Meet with your TA during office hours; Visit a campus computing center during CS110 Lab Support Hours Background In this assignment you will use the build another Scratch program. In this program you will be working more with variables, loops, random numbers and lists. _____________________________________________________________________ Goal This assignment will require you to create a Scratch program using lists. A list allows us to associate one variable name with multiple items or values. Scratch provides us with the following instructions and references. add item to end of list Delete item from list (in this case, the first item) adds item in a specified position in list (in this case, position 1) replaces item in list with some other value (in this case, item 1 replaced with thing). refers to an item in the list (in this case, item 1) refers to the number of items in the list. Deletes one (or all) elements from the list Deletes the element in position position http://scratch.mit.edu/ 2 from the list Example code using lists: Adding items to a list Open Scratch. Go to Variable block. Click on Make A List. Name the list food. The list is currently empty. Click on the + sign and add a food item. Do this at least three times. Reporting items in a list Make a new variable named count. Add the code on the right. o count will keep track of which item in the list you are looking at o repeat loop will execute as many times as it has items in the list o the first item I want is item #1 so I change count by 1. Then I want item #2 so the second time through the loop I increment count again. I do this until I've looked at each item. Hide your food list by un-checking the checkbox next to the list variable, food. Alternative method for adding items to a list: You can also populate your list by importing items from a text file. This way is much easier. Use a text editor to create a file named friends.txt. Add the following to your file, one per line and safe your text file. Mickey Mouse Donald Duck Tom and Jerry Bugs Bunny Tweety Bird Garfield Speedy Gonzales Pluto Bambi Create a Scratch list and name it friends. Right click on the empty friends list on the stage. Click import and navigate to friends.txt. Like magic, your list is populated and it has length 9. Modify your previous code segment: ...