90 likes | 103 Views
Learn about representing and manipulating data using lists and arrays. Explore concepts such as two-dimensional arrays, referencing elements, and calculating averages. Implement Tic Tac Toe game logic and explore advanced tasks like identifying ties and duplicating sprites.
E N D
CSC 170 Computing: Science and Creativity Big IDEAs: Data and Information, Algorithms, PROGRAMMINGLIST OF LISTS Institute for Personal Robots in Education (IPRE)
Data in rows and columns • Data is sometimes conveniently viewed as rows and columns Test# 1 2 3 4 a 82 73 67 81 b 99 86 72 87 c 100 91 83 92 d 72 76 52 78 e 54 43 0 0 f 86 85 84 83
Declaring Two-Dimensional Arrays • Data like this can be represented by a list of lists • the 1st list represents student a’s four test scores • Section1 is list of 6 lists of student’s tests
Referencing individual elements • Reference to 1 item in a list of lists requires two item ? of’s • This is the “upper left”, the first item in the first list of lists • This is the “lower right”, the last item in the last list of lists
Show TEST average for each student • Outer loop shows each student’s test average • Inner loop sums all tests See ListOfLIsts.xml
MODEL a Tic tac TOE board • Three lists representing a row of 3 blanks, Xs, or Os.
LAB TODAY: Task 1 • 1) Implement has ? won to return true of X or O has won
LAB TODAY: Task 2 • 2) Implement ends with a tie when all 9 items are either X or O and X has not won and O has not won
LAB TODAY: Task 3 • 3) Duplicate Sprite 1 7 times and make the appropriate changes • Change the argument to contains • Add sprite number to selected squares • Change the replace item and item of arguments 1 2 3 4 5 6 7 8 9