Date

### September 22, 2016

#### Activity 1: Login and Record Attendance

We will be taking roll in lab each week! Please come to your assigned lab to be counted present!

If you are in an Olsson lab, click "Lab Attendance" on the left-hand menu in Collab to register your attendance and keep up with your lab grade.
YOU MUST CLICK THE LARGE GREEN OR YELLOW BUTTON FOR YOUR ATTENDANCE TO COUNT!!

You must do this from a machine in Olsson 001 and not your laptop. If you have trouble, talk to your lab TA. Students in Lab 109 will do attendance via direction from the TA.

#### Activity 2: Take Quiz 2

While you are waiting for lab to start, click on Tests & Quizzes in Collab from either the desktop or laptop and take Quiz 2 - a very short review quiz on the material we have covered thus far. If you do not complete it today, you have until Sunday to do so.

#### Activity 3: Recitation

The TAs will do a lesson on decision structures and loops before moving on to the in-lab activity.

#### Activity 4: Magic Square Verifier

Most people are familiar with Sudoku, a number puzzle that consists of nine squares with nine squares within each of those squares in which you write the digits 1 through 9 so that each large square, row, and column all have exactly one instance of each digit.

A smaller, simpler form of that is the Lo Shu Magic Square. A Lo Shu Magic Square has 9 boxes in a grid in which you also put each digit from 1 through 9 exactly once. The difference is that each row, column, and diagonal all sum to the same value, 15.

For example:

``` 4 9 2 3 5 7 8 1 6 ```

For this lab, write a program called lo_shu.py that will take in 9 numbers in a particular order that represents a Lo Shu Magic Square. You should respond to the user whether the square is or is not a valid Lo Shu Magic Square.

Assume you had a square that looked like this:

``` 1 2 3 4 5 6 7 8 9 ```

Your program's output should look like this:

``` Numbers: 1 2 3 4 5 6 7 8 9 You entered: 1 2 3 4 5 6 7 8 9 [1, 2, 3] fails the test! [7, 8, 9] fails the test! Column 0 fails the test! Column 2 fails the test! This is not a Lo Shu Magic Square! ```

Another example might be:

``` 4 9 2 3 5 7 8 1 6 ```

Your program's output should look like this:

``` Numbers: 4 9 2 3 5 7 8 1 6 You entered: 4 9 2 3 5 7 8 1 6 This is a valid Lo Shu Magic Square! ```

While we know you could simply hardcode every possible row, column, and diagonal, you should intentionally make yourself do this with loops! Write a loop that will do ALL of the rows and another that will do ALL of the columns! The point of this lab is to help you with loops and if statements!

Consider you could do something like this to read in the square from the user:

```numbers = (input("Numbers: ")).split()

square = [[0,0,0],[0,0,0],[0,0,0]]
count = 0

for row in range(3):
for col in range(3):
square[row][col] = int(numbers[count])
count +=1
```

The double for loop here will allow you to populate the list of lists called `square` from a single list of `ints` that the user enters. You are not required to use the code above if you have another way you want to do it.

Submission: Each partner should submit one .py file named `lo_shu.py` to https://archimedes.cs.virginia.edu/cs1110/. Please put both partners' names and id's in two comments at the top of the file. The system is set to give quick feedback, so check to see if your solution worked!